prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Compile with AVX only
  Seems that TF2.4.0 is accidentally compiled with AVX2 (or more, not sure what's the CPU spec on TF release CI), and we follow it in https://github.com/tensorflow/addons/pull/2299. We should fallback to subset of ISAs, probably AVX, once there is a new release.
  
  https://github.com/tensorflow/tensorflow/pull/46229
  
  /cc @seanpmorgan 
  
  --- 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_linux():
  48     return platform.system() == "Linux"
  49 
  50 
  51 def is_raspi_arm():
  52     return os.uname()[4] == "armv7l"
  53 
  54 
  55 def get_tf_header_dir():
  56     import tensorflow as tf
  57 
  58     tf_header_dir = tf.sysconfig.get_compile_flags()[0][2:]
  59     if is_windows():
  60         tf_header_dir = tf_header_dir.replace("\\", "/")
  61     return tf_header_dir
  62 
  63 
  64 def get_tf_shared_lib_dir():
  65     import tensorflow as tf
  66 
  67     # OS Specific parsing
  68     if is_windows():
  69         tf_shared_lib_dir = tf.sysconfig.get_compile_flags()[0][2:-7] + "python"
  70         return tf_shared_lib_dir.replace("\\", "/")
  71     elif is_raspi_arm():
  72         return tf.sysconfig.get_compile_flags()[0][2:-7] + "python"
  73     else:
  74         return tf.sysconfig.get_link_flags()[0][2:]
  75 
  76 
  77 # Converts the linkflag namespec to the full shared library name
  78 def get_shared_lib_name():
  79     import tensorflow as tf
  80 
  81     namespec = tf.sysconfig.get_link_flags()
  82     if is_macos():
  83         # MacOS
  84         return "lib" + namespec[1][2:] + ".dylib"
  85     elif is_windows():
  86         # Windows
  87         return "_pywrap_tensorflow_internal.lib"
  88     elif is_raspi_arm():
  89         # The below command for linux would return an empty list
  90         return "_pywrap_tensorflow_internal.so"
  91     else:
  92         # Linux
  93         return namespec[1][3:]
  94 
  95 
  96 def create_build_configuration():
  97     print()
  98     print("Configuring TensorFlow Addons to be built from source...")
  99 
  100     if os.path.isfile(_TFA_BAZELRC):
  101         os.remove(_TFA_BAZELRC)
  102 
  103     logging.disable(logging.WARNING)
  104 
  105     write_action_env("TF_HEADER_DIR", get_tf_header_dir())
  106     write_action_env("TF_SHARED_LIBRARY_DIR", get_tf_shared_lib_dir())
  107     write_action_env("TF_SHARED_LIBRARY_NAME", get_shared_lib_name())
  108     write_action_env("TF_CXX11_ABI_FLAG", tf.sysconfig.CXX11_ABI_FLAG)
  109 
  110     write("build --spawn_strategy=standalone")
  111     write("build --strategy=Genrule=standalone")
  112     write("build -c opt")
  113 
  114     if is_windows():
  115         write("build --config=windows")
  116         write("build:windows --enable_runfiles")
  117         write("build:windows --copt=/experimental:preprocessor")
  118         write("build:windows --host_copt=/experimental:preprocessor")
  119         write("build:windows --copt=/arch=AVX2")
  120         write("build:windows --cxxopt=/std:c++14")
  121         write("build:windows --host_cxxopt=/std:c++14")
  122 
  123     if is_macos() or is_linux():
  124         write("build --copt=-mavx2")
  125         write("build --cxxopt=-std=c++14")
  126         write("build --host_cxxopt=-std=c++14")
  127 
  128     if os.getenv("TF_NEED_CUDA", "0") == "1":
  129         print("> Building GPU & CPU ops")
  130         configure_cuda()
  131     else:
  132         print("> Building only CPU ops")
  133 
  134     print()
  135     print("Build configurations successfully written to", _TFA_BAZELRC, ":\n")
  136     print(pathlib.Path(_TFA_BAZELRC).read_text())
  137 
  138 
  139 def configure_cuda():
  140     write_action_env("TF_NEED_CUDA", "1")
  141     write_action_env(
  142         "CUDA_TOOLKIT_PATH", os.getenv("CUDA_TOOLKIT_PATH", "/usr/local/cuda")
  143     )
  144     write_action_env(
  145         "CUDNN_INSTALL_PATH",
  146         os.getenv("CUDNN_INSTALL_PATH", "/usr/lib/x86_64-linux-gnu"),
  147     )
  148     write_action_env("TF_CUDA_VERSION", os.getenv("TF_CUDA_VERSION", "11"))
  149     write_action_env("TF_CUDNN_VERSION", os.getenv("TF_CUDNN_VERSION", "8"))
  150 
  151     write("test --config=cuda")
  152     write("build --config=cuda")
  153     write("build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true")
  154     write("build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain")
  155 
  156 
  157 if __name__ == "__main__":
  158     create_build_configuration()
  159
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/configure.py b/configure.py
  --- a/configure.py
  +++ b/configure.py
  @@ -116,12 +116,12 @@
           write("build:windows --enable_runfiles")
           write("build:windows --copt=/experimental:preprocessor")
           write("build:windows --host_copt=/experimental:preprocessor")
  -        write("build:windows --copt=/arch=AVX2")
  +        write("build:windows --copt=/arch=AVX")
           write("build:windows --cxxopt=/std:c++14")
           write("build:windows --host_cxxopt=/std:c++14")
   
       if is_macos() or is_linux():
  -        write("build --copt=-mavx2")
  +        write("build --copt=-mavx")
           write("build --cxxopt=-std=c++14")
           write("build --host_cxxopt=-std=c++14")
  
verification_info: {"golden_diff": "diff --git a/configure.py b/configure.py\n--- a/configure.py\n+++ b/configure.py\n@@ -116,12 +116,12 @@\n         write(\"build:windows --enable_runfiles\")\n         write(\"build:windows --copt=/experimental:preprocessor\")\n         write(\"build:windows --host_copt=/experimental:preprocessor\")\n-        write(\"build:windows --copt=/arch=AVX2\")\n+        write(\"build:windows --copt=/arch=AVX\")\n         write(\"build:windows --cxxopt=/std:c++14\")\n         write(\"build:windows --host_cxxopt=/std:c++14\")\n \n     if is_macos() or is_linux():\n-        write(\"build --copt=-mavx2\")\n+        write(\"build --copt=-mavx\")\n         write(\"build --cxxopt=-std=c++14\")\n         write(\"build --host_cxxopt=-std=c++14\")\n", "issue": "Compile with AVX only\nSeems that TF2.4.0 is accidentally compiled with AVX2 (or more, not sure what's the CPU spec on TF release CI), and we follow it in https://github.com/tensorflow/addons/pull/2299. We should fallback to subset of ISAs, probably AVX, once there is a new release.\r\n\r\nhttps://github.com/tensorflow/tensorflow/pull/46229\r\n\r\n/cc @seanpmorgan \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_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 --enable_runfiles\")\n        write(\"build:windows --copt=/experimental:preprocessor\")\n        write(\"build:windows --host_copt=/experimental:preprocessor\")\n        write(\"build:windows --copt=/arch=AVX2\")\n        write(\"build:windows --cxxopt=/std:c++14\")\n        write(\"build:windows --host_cxxopt=/std:c++14\")\n\n    if is_macos() or is_linux():\n        write(\"build --copt=-mavx2\")\n        write(\"build --cxxopt=-std=c++14\")\n        write(\"build --host_cxxopt=-std=c++14\")\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 --enable_runfiles\")\n        write(\"build:windows --copt=/experimental:preprocessor\")\n        write(\"build:windows --host_copt=/experimental:preprocessor\")\n        write(\"build:windows --copt=/arch=AVX\")\n        write(\"build:windows --cxxopt=/std:c++14\")\n        write(\"build:windows --host_cxxopt=/std:c++14\")\n\n    if is_macos() or is_linux():\n        write(\"build --copt=-mavx\")\n        write(\"build --cxxopt=-std=c++14\")\n        write(\"build --host_cxxopt=-std=c++14\")\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"}]}