diff --git a/packages/py-tensorflow/package.py b/packages/py-tensorflow/package.py
index 6b01431b6faa4ce83ebfa02435a54be0e91e5e37..5b858b1e4843af388551c02037a8c28263c71931 100644
--- a/packages/py-tensorflow/package.py
+++ b/packages/py-tensorflow/package.py
@@ -560,6 +560,14 @@ class PyTensorflow(Package, CudaPackage, ROCmPackage, PythonExtension):
     patch("set_jit_true.patch", when="@2.18.0-rocm-enhanced +rocm")
     phases = ["configure", "build", "install"]
 
+    # see https://github.com/tensorflow/tensorflow/pull/74423
+    # ("Fix ResolvePadding to be consistent in the size of the small vector")
+    patch(
+        "https://github.com/tensorflow/tensorflow/commit/64b7390208319b239d0fedb146b2969fbdbf0ee6.patch?full_index=1",
+        sha256="2eac2f361ee71c26d129e281990e6a84114c3898dda6178f4510e715e9dbcc95",
+        when="@2.18.0 %gcc",
+    )
+
     def flag_handler(self, name, flags):
         spec = self.spec
         # ubuntu gcc has this workaround turned on by default in aarch64
@@ -915,6 +923,11 @@ class PyTensorflow(Package, CudaPackage, ROCmPackage, PythonExtension):
         filter_file("build:opt --copt=-march=native", "", ".tf_configure.bazelrc")
         filter_file("build:opt --host_copt=-march=native", "", ".tf_configure.bazelrc")
 
+        # option -mavxvnniint8 (via @2.18's xnnpack) only supported from gcc@13:
+        if spec.satisfies("@2.18.0: %gcc@:12"):
+            with open(".bazelrc", mode="a") as f:
+                f.write("build --define=xnn_enable_avxvnniint8=false\n")
+
     def build(self, spec, prefix):
         # Bazel needs the directory to exist on install
         mkdirp(python_platlib)