We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Enable SSE4.2 and AVX support during build
So the pip installed TF does not support these instruction sets by default, but modern-ish CPUs do. (Roughly CPUs after 2012).

We could try this and see if there are any improvements in test times and weight the benefits.  If nothing else we can add it as a flag for building from source. Currently TF-IO does this by default:
https://github.com/tensorflow/io/blob/master/.github/workflows/build.yml#L13

@perfinion do we know if this is on the roadmap for default TF installations?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `configure.py`
Content:
```
1 # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 # ==============================================================================
15 # Usage: python configure.py
16 #
17 
18 
19 import os
20 import pathlib
21 import platform
22 import logging
23 
24 import tensorflow as tf
25 
26 _TFA_BAZELRC = ".bazelrc"
27 
28 
29 # Writes variables to bazelrc file
30 def write(line):
31     with open(_TFA_BAZELRC, "a") as f:
32         f.write(line + "\n")
33 
34 
35 def write_action_env(var_name, var):
36     write('build --action_env {}="{}"'.format(var_name, var))
37 
38 
39 def is_macos():
40     return platform.system() == "Darwin"
41 
42 
43 def is_windows():
44     return platform.system() == "Windows"
45 
46 
47 def is_raspi_arm():
48     return os.uname()[4] == "armv7l"
49 
50 
51 def get_tf_header_dir():
52     import tensorflow as tf
53 
54     tf_header_dir = tf.sysconfig.get_compile_flags()[0][2:]
55     if is_windows():
56         tf_header_dir = tf_header_dir.replace("\\", "/")
57     return tf_header_dir
58 
59 
60 def get_tf_shared_lib_dir():
61     import tensorflow as tf
62 
63     # OS Specific parsing
64     if is_windows():
65         tf_shared_lib_dir = tf.sysconfig.get_compile_flags()[0][2:-7] + "python"
66         return tf_shared_lib_dir.replace("\\", "/")
67     elif is_raspi_arm():
68         return tf.sysconfig.get_compile_flags()[0][2:-7] + "python"
69     else:
70         return tf.sysconfig.get_link_flags()[0][2:]
71 
72 
73 # Converts the linkflag namespec to the full shared library name
74 def get_shared_lib_name():
75     import tensorflow as tf
76 
77     namespec = tf.sysconfig.get_link_flags()
78     if is_macos():
79         # MacOS
80         return "lib" + namespec[1][2:] + ".dylib"
81     elif is_windows():
82         # Windows
83         return "_pywrap_tensorflow_internal.lib"
84     elif is_raspi_arm():
85         # The below command for linux would return an empty list
86         return "_pywrap_tensorflow_internal.so"
87     else:
88         # Linux
89         return namespec[1][3:]
90 
91 
92 def create_build_configuration():
93     print()
94     print("Configuring TensorFlow Addons to be built from source...")
95 
96     if os.path.isfile(_TFA_BAZELRC):
97         os.remove(_TFA_BAZELRC)
98 
99     logging.disable(logging.WARNING)
100 
101     write_action_env("TF_HEADER_DIR", get_tf_header_dir())
102     write_action_env("TF_SHARED_LIBRARY_DIR", get_tf_shared_lib_dir())
103     write_action_env("TF_SHARED_LIBRARY_NAME", get_shared_lib_name())
104     write_action_env("TF_CXX11_ABI_FLAG", tf.sysconfig.CXX11_ABI_FLAG)
105 
106     write("build --spawn_strategy=standalone")
107     write("build --strategy=Genrule=standalone")
108     write("build -c opt")
109 
110     if is_windows():
111         write("build --config=windows")
112         write("build:windows --copt=/experimental:preprocessor")
113         write("build:windows --host_copt=/experimental:preprocessor")
114 
115     if os.getenv("TF_NEED_CUDA", "0") == "1":
116         print("> Building GPU & CPU ops")
117         configure_cuda()
118     else:
119         print("> Building only CPU ops")
120 
121     print()
122     print("Build configurations successfully written to", _TFA_BAZELRC, ":\n")
123     print(pathlib.Path(_TFA_BAZELRC).read_text())
124 
125 
126 def configure_cuda():
127     write_action_env("TF_NEED_CUDA", "1")
128     write_action_env(
129         "CUDA_TOOLKIT_PATH", os.getenv("CUDA_TOOLKIT_PATH", "/usr/local/cuda")
130     )
131     write_action_env(
132         "CUDNN_INSTALL_PATH",
133         os.getenv("CUDNN_INSTALL_PATH", "/usr/lib/x86_64-linux-gnu"),
134     )
135     write_action_env("TF_CUDA_VERSION", os.getenv("TF_CUDA_VERSION", "11"))
136     write_action_env("TF_CUDNN_VERSION", os.getenv("TF_CUDNN_VERSION", "8"))
137 
138     write("test --config=cuda")
139     write("build --config=cuda")
140     write("build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true")
141     write("build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain")
142 
143 
144 if __name__ == "__main__":
145     create_build_configuration()
146
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/configure.py b/configure.py
--- a/configure.py
+++ b/configure.py
@@ -44,6 +44,10 @@
     return platform.system() == "Windows"
 
 
+def is_linux():
+    return platform.system() == "Linux"
+
+
 def is_raspi_arm():
     return os.uname()[4] == "armv7l"
 
@@ -111,6 +115,10 @@
         write("build --config=windows")
         write("build:windows --copt=/experimental:preprocessor")
         write("build:windows --host_copt=/experimental:preprocessor")
+        write("build:windows --copt=/arch=AVX2")
+
+    if is_macos() or is_linux():
+        write("build --copt=-mavx2")
 
     if os.getenv("TF_NEED_CUDA", "0") == "1":
         print("> Building GPU & CPU ops")

{"golden_diff": "diff --git a/configure.py b/configure.py\n--- a/configure.py\n+++ b/configure.py\n@@ -44,6 +44,10 @@\n     return platform.system() == \"Windows\"\n \n \n+def is_linux():\n+    return platform.system() == \"Linux\"\n+\n+\n def is_raspi_arm():\n     return os.uname()[4] == \"armv7l\"\n \n@@ -111,6 +115,10 @@\n         write(\"build --config=windows\")\n         write(\"build:windows --copt=/experimental:preprocessor\")\n         write(\"build:windows --host_copt=/experimental:preprocessor\")\n+        write(\"build:windows --copt=/arch=AVX2\")\n+\n+    if is_macos() or is_linux():\n+        write(\"build --copt=-mavx2\")\n \n     if os.getenv(\"TF_NEED_CUDA\", \"0\") == \"1\":\n         print(\"> Building GPU & CPU ops\")\n", "issue": "Enable SSE4.2 and AVX support during build\nSo the pip installed TF does not support these instruction sets by default, but modern-ish CPUs do. (Roughly CPUs after 2012).\r\n\r\nWe could try this and see if there are any improvements in test times and weight the benefits.  If nothing else we can add it as a flag for building from source. Currently TF-IO does this by default:\r\nhttps://github.com/tensorflow/io/blob/master/.github/workflows/build.yml#L13\r\n\r\n@perfinion do we know if this is on the roadmap for default TF installations?\n", "before_files": [{"content": "# Copyright 2020 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n# Usage: python configure.py\n#\n\n\nimport os\nimport pathlib\nimport platform\nimport logging\n\nimport tensorflow as tf\n\n_TFA_BAZELRC = \".bazelrc\"\n\n\n# Writes variables to bazelrc file\ndef write(line):\n    with open(_TFA_BAZELRC, \"a\") as f:\n        f.write(line + \"\\n\")\n\n\ndef write_action_env(var_name, var):\n    write('build --action_env {}=\"{}\"'.format(var_name, var))\n\n\ndef is_macos():\n    return platform.system() == \"Darwin\"\n\n\ndef is_windows():\n    return platform.system() == \"Windows\"\n\n\ndef is_raspi_arm():\n    return os.uname()[4] == \"armv7l\"\n\n\ndef get_tf_header_dir():\n    import tensorflow as tf\n\n    tf_header_dir = tf.sysconfig.get_compile_flags()[0][2:]\n    if is_windows():\n        tf_header_dir = tf_header_dir.replace(\"\\\\\", \"/\")\n    return tf_header_dir\n\n\ndef get_tf_shared_lib_dir():\n    import tensorflow as tf\n\n    # OS Specific parsing\n    if is_windows():\n        tf_shared_lib_dir = tf.sysconfig.get_compile_flags()[0][2:-7] + \"python\"\n        return tf_shared_lib_dir.replace(\"\\\\\", \"/\")\n    elif is_raspi_arm():\n        return tf.sysconfig.get_compile_flags()[0][2:-7] + \"python\"\n    else:\n        return tf.sysconfig.get_link_flags()[0][2:]\n\n\n# Converts the linkflag namespec to the full shared library name\ndef get_shared_lib_name():\n    import tensorflow as tf\n\n    namespec = tf.sysconfig.get_link_flags()\n    if is_macos():\n        # MacOS\n        return \"lib\" + namespec[1][2:] + \".dylib\"\n    elif is_windows():\n        # Windows\n        return \"_pywrap_tensorflow_internal.lib\"\n    elif is_raspi_arm():\n        # The below command for linux would return an empty list\n        return \"_pywrap_tensorflow_internal.so\"\n    else:\n        # Linux\n        return namespec[1][3:]\n\n\ndef create_build_configuration():\n    print()\n    print(\"Configuring TensorFlow Addons to be built from source...\")\n\n    if os.path.isfile(_TFA_BAZELRC):\n        os.remove(_TFA_BAZELRC)\n\n    logging.disable(logging.WARNING)\n\n    write_action_env(\"TF_HEADER_DIR\", get_tf_header_dir())\n    write_action_env(\"TF_SHARED_LIBRARY_DIR\", get_tf_shared_lib_dir())\n    write_action_env(\"TF_SHARED_LIBRARY_NAME\", get_shared_lib_name())\n    write_action_env(\"TF_CXX11_ABI_FLAG\", tf.sysconfig.CXX11_ABI_FLAG)\n\n    write(\"build --spawn_strategy=standalone\")\n    write(\"build --strategy=Genrule=standalone\")\n    write(\"build -c opt\")\n\n    if is_windows():\n        write(\"build --config=windows\")\n        write(\"build:windows --copt=/experimental:preprocessor\")\n        write(\"build:windows --host_copt=/experimental:preprocessor\")\n\n    if os.getenv(\"TF_NEED_CUDA\", \"0\") == \"1\":\n        print(\"> Building GPU & CPU ops\")\n        configure_cuda()\n    else:\n        print(\"> Building only CPU ops\")\n\n    print()\n    print(\"Build configurations successfully written to\", _TFA_BAZELRC, \":\\n\")\n    print(pathlib.Path(_TFA_BAZELRC).read_text())\n\n\ndef configure_cuda():\n    write_action_env(\"TF_NEED_CUDA\", \"1\")\n    write_action_env(\n        \"CUDA_TOOLKIT_PATH\", os.getenv(\"CUDA_TOOLKIT_PATH\", \"/usr/local/cuda\")\n    )\n    write_action_env(\n        \"CUDNN_INSTALL_PATH\",\n        os.getenv(\"CUDNN_INSTALL_PATH\", \"/usr/lib/x86_64-linux-gnu\"),\n    )\n    write_action_env(\"TF_CUDA_VERSION\", os.getenv(\"TF_CUDA_VERSION\", \"11\"))\n    write_action_env(\"TF_CUDNN_VERSION\", os.getenv(\"TF_CUDNN_VERSION\", \"8\"))\n\n    write(\"test --config=cuda\")\n    write(\"build --config=cuda\")\n    write(\"build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true\")\n    write(\"build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain\")\n\n\nif __name__ == \"__main__\":\n    create_build_configuration()\n", "path": "configure.py"}], "after_files": [{"content": "# Copyright 2020 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n# Usage: python configure.py\n#\n\n\nimport os\nimport pathlib\nimport platform\nimport logging\n\nimport tensorflow as tf\n\n_TFA_BAZELRC = \".bazelrc\"\n\n\n# Writes variables to bazelrc file\ndef write(line):\n    with open(_TFA_BAZELRC, \"a\") as f:\n        f.write(line + \"\\n\")\n\n\ndef write_action_env(var_name, var):\n    write('build --action_env {}=\"{}\"'.format(var_name, var))\n\n\ndef is_macos():\n    return platform.system() == \"Darwin\"\n\n\ndef is_windows():\n    return platform.system() == \"Windows\"\n\n\ndef is_linux():\n    return platform.system() == \"Linux\"\n\n\ndef is_raspi_arm():\n    return os.uname()[4] == \"armv7l\"\n\n\ndef get_tf_header_dir():\n    import tensorflow as tf\n\n    tf_header_dir = tf.sysconfig.get_compile_flags()[0][2:]\n    if is_windows():\n        tf_header_dir = tf_header_dir.replace(\"\\\\\", \"/\")\n    return tf_header_dir\n\n\ndef get_tf_shared_lib_dir():\n    import tensorflow as tf\n\n    # OS Specific parsing\n    if is_windows():\n        tf_shared_lib_dir = tf.sysconfig.get_compile_flags()[0][2:-7] + \"python\"\n        return tf_shared_lib_dir.replace(\"\\\\\", \"/\")\n    elif is_raspi_arm():\n        return tf.sysconfig.get_compile_flags()[0][2:-7] + \"python\"\n    else:\n        return tf.sysconfig.get_link_flags()[0][2:]\n\n\n# Converts the linkflag namespec to the full shared library name\ndef get_shared_lib_name():\n    import tensorflow as tf\n\n    namespec = tf.sysconfig.get_link_flags()\n    if is_macos():\n        # MacOS\n        return \"lib\" + namespec[1][2:] + \".dylib\"\n    elif is_windows():\n        # Windows\n        return \"_pywrap_tensorflow_internal.lib\"\n    elif is_raspi_arm():\n        # The below command for linux would return an empty list\n        return \"_pywrap_tensorflow_internal.so\"\n    else:\n        # Linux\n        return namespec[1][3:]\n\n\ndef create_build_configuration():\n    print()\n    print(\"Configuring TensorFlow Addons to be built from source...\")\n\n    if os.path.isfile(_TFA_BAZELRC):\n        os.remove(_TFA_BAZELRC)\n\n    logging.disable(logging.WARNING)\n\n    write_action_env(\"TF_HEADER_DIR\", get_tf_header_dir())\n    write_action_env(\"TF_SHARED_LIBRARY_DIR\", get_tf_shared_lib_dir())\n    write_action_env(\"TF_SHARED_LIBRARY_NAME\", get_shared_lib_name())\n    write_action_env(\"TF_CXX11_ABI_FLAG\", tf.sysconfig.CXX11_ABI_FLAG)\n\n    write(\"build --spawn_strategy=standalone\")\n    write(\"build --strategy=Genrule=standalone\")\n    write(\"build -c opt\")\n\n    if is_windows():\n        write(\"build --config=windows\")\n        write(\"build:windows --copt=/experimental:preprocessor\")\n        write(\"build:windows --host_copt=/experimental:preprocessor\")\n        write(\"build:windows --copt=/arch=AVX2\")\n\n    if is_macos() or is_linux():\n        write(\"build --copt=-mavx2\")\n\n    if os.getenv(\"TF_NEED_CUDA\", \"0\") == \"1\":\n        print(\"> Building GPU & CPU ops\")\n        configure_cuda()\n    else:\n        print(\"> Building only CPU ops\")\n\n    print()\n    print(\"Build configurations successfully written to\", _TFA_BAZELRC, \":\\n\")\n    print(pathlib.Path(_TFA_BAZELRC).read_text())\n\n\ndef configure_cuda():\n    write_action_env(\"TF_NEED_CUDA\", \"1\")\n    write_action_env(\n        \"CUDA_TOOLKIT_PATH\", os.getenv(\"CUDA_TOOLKIT_PATH\", \"/usr/local/cuda\")\n    )\n    write_action_env(\n        \"CUDNN_INSTALL_PATH\",\n        os.getenv(\"CUDNN_INSTALL_PATH\", \"/usr/lib/x86_64-linux-gnu\"),\n    )\n    write_action_env(\"TF_CUDA_VERSION\", os.getenv(\"TF_CUDA_VERSION\", \"11\"))\n    write_action_env(\"TF_CUDNN_VERSION\", os.getenv(\"TF_CUDNN_VERSION\", \"8\"))\n\n    write(\"test --config=cuda\")\n    write(\"build --config=cuda\")\n    write(\"build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true\")\n    write(\"build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain\")\n\n\nif __name__ == \"__main__\":\n    create_build_configuration()\n", "path": "configure.py"}]}