Repository: tensorflow
Issue: QuantizedOpsTest.testAxis fails on cascade lake CPUs
Labels: stat:awaiting tensorflower,type:bug,comp:ops,TF 2.9

**System information**
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): no 
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux RHEL 8.3
- TensorFlow installed from (source or binary): source
- TensorFlow version (use command below): 2.5.0
- Python version: 3.8.6
- Bazel version (if compiling from source): 3.7.2
- GCC/Compiler version (if compiling from source): GCC 10.2.0
- CUDA/cuDNN version: None

**Describe the current behavior**

QuantizedOpsTest.testAxis fails on cascade lake systems when native optimizations are enabled

**Standalone code to reproduce the issue**

Run the TF test `//tensorflow/python:quantized_ops_test` through bazel

**Other info / logs**
```
FAIL: testAxis (__main__.QuantizedOpsTest)
QuantizedOpsTest.testAxis
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/dev/shm/build-branfosj-admin/branfosj-admin-up/TensorFlow/2.5.0/foss-2020b/tmp8qildda2-bazel-tf/1b512851602cc5932dcb1cd30c5fbde4/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/python/quantized_ops_test.runfiles/org_tensorflow/tensorflow/python/ops/quantized_ops_test.py", line 94, in testAxis
    self.assertAllEqual(quantized, expected_quantized)
  File "/dev/shm/build-branfosj-admin/branfosj-admin-up/TensorFlow/2.5.0/foss-2020b/tmp8qildda2-bazel-tf/1b512851602cc5932dcb1cd30c5fbde4/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/python/quantized_ops_test.runfiles/org_tensorflow/tensorflow/python/framework/test_util.py", line 1253, in decorated
    return f(*args, **kwds)
  File "/dev/shm/build-branfosj-admin/branfosj-admin-up/TensorFlow/2.5.0/foss-2020b/tmp8qildda2-bazel-tf/1b512851602cc5932dcb1cd30c5fbde4/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/python/quantized_ops_test.runfiles/org_tensorflow/tensorflow/python/framework/test_util.py", line 2881, in assertAllEqual
    np.testing.assert_array_equal(a, b, err_msg="\n".join(msgs))
  File "/rds/bear-apps/devel/eb-sjb-up/EL8/EL8-cas/software/SciPy-bundle/2020.11-foss-2020b/lib/python3.8/site-packages/numpy/testing/_private/utils.py", line 930, in assert_array_equal
    assert_array_compare(operator.__eq__, x, y, err_msg=err_msg,
  File "/rds/bear-apps/devel/eb-sjb-up/EL8/EL8-cas/software/SciPy-bundle/2020.11-foss-2020b/lib/python3.8/site-packages/numpy/testing/_private/utils.py", line 840, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

not equal where = (array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]), array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
       2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0]), array([0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 1,
       1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1,
       1, 1, 2, 2, 2, 2, 2, 3, 0, 0, 0, 0]), array([0, 1, 2, 3, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0,
       1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2,
       3, 4, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3]))
not equal lhs = array([ -64,    0,   38,  102,   38,  102,   71,   64,   64, -128,  -64,
          0,  102,   71,   64, -128, -128,  -64,    0,   38,   64, -128,
        -64,    0,    0,   38,  102,   71,    0,   38,  102,   71,   71,
         64, -128,  -64,  102,   71,   64, -128, -128,  -64,    0,   38,
         71,   64, -128,  -64,  -64,    0,   38,  102,   38,  102,   71,
         64], dtype=int8)
not equal rhs = array([-128,  -64,    0,   38,  -64,    0,   38,  102,   71,   64, -128,
        -64,    0,   38,  102,   71,   64, -128,  -64,    0,   38,  102,
         71,   64, -128,  -64,    0,   38,  102,   71,   64, -128,  -64,
          0,   38,  102,   71,   64, -128,  -64,    0,   38,  102,   71,
         64, -128,  -64,    0,   38,  102,   71,   64,  102,   71,   64,
       -128], dtype=int32)
Mismatched elements: 56 / 120 (46.7%)
Max absolute difference: 230
Max relative difference: 4.36842105
 x: array([[[[ -64,    0,   38,  102,  102],
         [  71,   64, -128,   38,  102],
         [  71,   64,   64, -128,  -64],...
 y: array([[[[-128,  -64,    0,   38,  102],
         [  71,   64, -128,  -64,    0],
         [  38,  102,   71,   64, -128],...
```

This seems to be related to https://github.com/tensorflow/tensorflow/issues/47179 which can also only be observed on cascade lake systems.