Repository: pytorch
Issue: Test Failure: TestUnaryUfuncsCPU.test_reference_numerics_normal_cos_cpu_float32 on s390x
Labels: triaged,module: numpy

### 🐛 Describe the bug

When I execute the following test case on s390x, I got the failure.

```python
$ python test/test_unary_ufuncs.py TestUnaryUfuncsCPU.test_reference_numerics_normal_cos_cpu_float32
...
======================================================================
FAIL: test_reference_numerics_normal_cos_cpu_float32 (__main__.TestUnaryUfuncsCPU)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ishizaki/PyTorch/master/torch/testing/_internal/common_device_type.py", line 401, in instantiated_test
    result = test(self, **param_kwargs)
  File "/home/ishizaki/PyTorch/master/torch/testing/_internal/common_device_type.py", line 851, in test_wrapper
    return test(*args, **kwargs)
  File "/home/ishizaki/PyTorch/master/torch/testing/_internal/common_utils.py", line 1390, in wrapper
    fn(*args, **kwargs)
  File "/home/ishizaki/PyTorch/master/test/test_unary_ufuncs.py", line 284, in test_reference_numerics_normal
    self._test_reference_numerics(dtype, op, tensors)
  File "/home/ishizaki/PyTorch/master/test/test_unary_ufuncs.py", line 265, in _test_reference_numerics
    _helper_reference_numerics(
  File "/home/ishizaki/PyTorch/master/test/test_unary_ufuncs.py", line 217, in _helper_reference_numerics
    self.assertEqualHelper(
  File "/home/ishizaki/PyTorch/master/test/test_unary_ufuncs.py", line 171, in assertEqualHelper
    self.assertEqual(
  File "/home/ishizaki/PyTorch/master/torch/testing/_internal/common_utils.py", line 3023, in assertEqual
    raise error_metas[0].to_error(
AssertionError: Tensor-likes are not close!

Mismatched elements: 42 / 943593 (0.0%)
Greatest absolute difference: 0.9999842047691345 at index (814, 548) (up to 1e-05 allowed)
Greatest relative difference: inf at index (28, 413) (up to 1.3e-06 allowed)

----------------------------------------------------------------------
Ran 1 test in 132.550s

FAILED (failures=1)
```

I realized that elements at particular positions (e.g. 28, 413) have different values. The expected value (generated by numpy) is 0 while the non-zero value is expected.

I can reproduce this problem by using the following code (Python 3.10.6, numpy 1.24.2). The value of `tc[28][414]` must be `0.5403023` rather than `0.0`.

```python
$ python -c "import torch; import numpy; t = torch.Tensor(1029,917).cpu().numpy(); t[0][0]=1; t[28][413]=1; tc = numpy.cos(t); print(t[0][0], tc[0][0], t[28][413], tc[28][413])"
1.0 0.5403023 1.0 0.0
$ python -c "import torch; import numpy; t = torch.Tensor(1029,917).cpu().numpy(); t[0][0]=1; t[28][414]=1; tc = numpy.cos(t); print(t[0][0], tc[0][0], t[28][414], tc[28][414])"
1.0 0.5403023 1.0 0.0
$ python -c "import torch; import numpy; t = torch.Tensor(1029,917).cpu(); t[0][0]=1; t[28][413]=1; tc = torch.cos(t); print(t[0][0], tc[0][0], t[28][413], tc[28][413])"
tensor(1.) tensor(0.5403) tensor(1.) tensor(0.5403)
$ python -c "import torch; import numpy; t = torch.Tensor(1029,917).cpu(); t[0][0]=1; t[28][414]=1; tc = torch.cos(t); print(t[0][0], tc[0][0], t[28][414], tc[28][414])"
tensor(1.) tensor(0.5403) tensor(1.) tensor(0.5403)
```

### Versions

```
Collecting environment information...
PyTorch version: 2.1.0a0+gite3df6a7
Is debug build: True
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.1 LTS (s390x)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.4.0-144-generic-s390x-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: False

Versions of relevant libraries:
[pip3] numpy==1.24.2
[pip3] torch==2.1.0a0+gite3df6a7
[conda] Could not collect
```


cc @mruberry @rgommers