Repository: pytorch
Issue: Race condition between torch.tensor's view and /= (/= returns incorrect result)
Labels: triaged,module: partial aliasing

### 🐛 Describe the bug

I found a race condition on some of my CPU families. Basically the operation v /= v[-1] with v = [a, b, c, d] delivers random results of the type:
v = [a/d, b, c/d, 1]
or
v = [a/d, b/d, c, 1]
My uneducated guess is that at a random moment the operation v[-1]/v[-1] = 1 is executed and then the result is used as new v[-1] (i.e. v /= 1) for the rest of the calculation.
 
Some of my CPUs show the problem and some don't (see down below in the version section). 

First I thought it is a problem of the new E/P core concept of the i9-12900K. Then I found it on a dual CPU system Xeon too. And finally I found it on an AMD 2. gen EPYC mono CPU. However, normal traditonal desktop CPU doesn't show the problem. 

```
import torch
A: torch.Tensor = torch.full((24, 75, 24, 24), 2, dtype=torch.float32)
B: torch.Tensor = A[:, -1, :, :].unsqueeze(1)
A /= B
print(A[:, 0, 0, 0])
```
(EDIT: A = A / B doesn't show this problem.)

My expectation is (and this is the result on an old i7-5820K):
```
tensor([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
        1., 1., 1., 1., 1., 1.])
```
but I get on i9-12900K CPUs
```
tensor([1., 2., 1., 1., 2., 1., 1., 2., 1., 1., 2., 1., 1., 1., 1., 1., 2., 1.,
        1., 2., 1., 1., 2., 1.]
```


### Versions

**Bad computer: i9-12900K**

Collecting environment information...
PyTorch version: 1.11.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Fedora release 36 (Thirty Six) (x86_64)
GCC version: (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1)
Clang version: 14.0.0 (Fedora 14.0.0-1.fc36)
CMake version: version 3.22.2
Libc version: glibc-2.35

Python version: 3.10.4 (main, Apr  6 2022, 17:03:02) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] (64-bit runtime)
Python platform: Linux-5.17.7-300.fc36.x86_64-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
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: True

Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] torch==1.11.0
[pip3] torch-tb-profiler==0.3.1
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] Could not collect


**Good computer: i7-5820K**

Collecting environment information...
PyTorch version: 1.11.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Fedora release 36 (Thirty Six) (x86_64)
GCC version: (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1)
Clang version: 14.0.0 (Fedora 14.0.0-1.fc36)
CMake version: version 3.22.2
Libc version: glibc-2.35

Python version: 3.10.4 (main, Apr  2 2022, 19:00:15) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)] (64-bit runtime)
Python platform: Linux-5.17.9-300.fc36.x86_64-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 980 Ti
Nvidia driver version: 510.68.02
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] torch==1.11.0
[pip3] torch-tb-profiler==0.4.0
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] Could not collect

**Bad computer: dual E5-2640**

Collecting environment information...
PyTorch version: 1.11.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Fedora release 36 (Thirty Six) (x86_64)
GCC version: (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1)
Clang version: 14.0.0 (Fedora 14.0.0-1.fc36)
CMake version: version 3.22.2
Libc version: glibc-2.35

Python version: 3.10.4 (main, Apr  6 2022, 17:03:02) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] (64-bit runtime)
Python platform: Linux-5.17.7-300.fc36.x86_64-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
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: True

Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] torch==1.11.0
[pip3] torch-tb-profiler==0.3.1
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] Could not collect

**Good computer: i7-3930K**
Collecting environment information...
PyTorch version: 1.11.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Fedora release 36 (Thirty Six) (x86_64)
GCC version: (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1)
Clang version: 14.0.0 (Fedora 14.0.0-1.fc36)
CMake version: version 3.22.2
Libc version: glibc-2.35

Python version: 3.10.4 (main, Apr  6 2022, 17:03:02) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] (64-bit runtime)
Python platform: Linux-5.17.7-300.fc36.x86_64-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
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: True

Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] torch==1.11.0
[pip3] torch-tb-profiler==0.3.1
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] Could not collect

**Bad computer: AMD EPYC 7282**
Collecting environment information...
PyTorch version: 1.11.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Fedora release 36 (Thirty Six) (x86_64)
GCC version: (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1)
Clang version: 14.0.0 (Fedora 14.0.0-1.fc36)
CMake version: version 3.22.2
Libc version: glibc-2.35

Python version: 3.10.4 (main, Apr  6 2022, 17:03:02) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] (64-bit runtime)
Python platform: Linux-5.17.7-300.fc36.x86_64-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
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: True

Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] torch==1.11.0
[pip3] torch-tb-profiler==0.3.1
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] Could not collect



cc @svekars @holly1238