Repository: pytorch
Issue: Unwanted behavior with some in-place operations on CPU
Labels: triaged,module: viewing and reshaping

### 🐛 Describe the bug

When doing in-place operations on a CPU such as subtracting a column from all columns of a tensor, the following behavior occurs:
```python
import torch
a = torch.Tensor([[1, 2, 3], [4, 5, 6]])
a -= a[:, 0, None]
print(a)  # tensor([[0., 2., 3.], [0., 5., 6.]])
```
It seems like the operation is processed sequentially, which is why a zero tensor is subtracted from the last two columns.

However, when performing the same operation with a tensor of size (2, 16), the first column is "correctly" subtracted from all columns:
```python
import torch
b = torch.ones((2, 16))
b -= b[:, 0, None]
print(torch.count_nonzero(b))  # tensor(0)
assert torch.count_nonzero(b) == 0
```

For a tensor of size (2, 17), the first 16 columns are processed "correctly", with the last one again being processed with the already updated version of the first column:
```python
import torch
c = torch.ones((2, 17))
c -= c[:, 0, None]
print(torch.count_nonzero(c[:, :16]))  # tensor(0)
print(c[:, 16])  # tensor([1., 1.])
```

When running the same code on a GPU, the first version of the first column is always subtracted from all columns.
NumPy (on a CPU) also has the same behavior as PyTorch on a GPU.

It would be nice to get a warning when attempting to run such operations on the CPU, or otherwise to adopt the NumPy behavior and always broadcast the original slice of the tensor.


### Versions

Collecting environment information...
PyTorch version: 1.11.0
Is debug build: False
CUDA used to build PyTorch: 11.3
ROCM used to build PyTorch: N/A

OS: openSUSE Leap 15.3 (x86_64)
GCC version: (SUSE Linux) 7.5.0
Clang version: 11.0.1
CMake version: version 3.17.0
Libc version: glibc-2.31

Python version: 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:39:04) [GCC 10.3.0] (64-bit runtime)
Python platform: Linux-5.3.18-150300.59.54-default-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 510.47.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.5
[pip3] torch==1.11.0
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.3.1               h2bc3f7f_2  
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.4.0           h06a4308_640  
[conda] mkl-fft                   1.3.1                    pypi_0    pypi
[conda] mkl-random                1.2.2                    pypi_0    pypi
[conda] mkl-service               2.4.0                    pypi_0    pypi
[conda] mkl_fft                   1.3.1           py310h2b4bcf5_1    conda-forge
[conda] mkl_random                1.2.2           py310h00e6091_0  
[conda] numpy                     1.21.5                   pypi_0    pypi
[conda] numpy-base                1.21.5          py310h9585f30_2  
[conda] pytorch                   1.11.0          py3.10_cuda11.3_cudnn8.2.0_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torch                     1.11.0                   pypi_0    pypi
[conda] torchaudio                0.11.0                   pypi_0    pypi
[conda] torchvision               0.12.0                   pypi_0    pypi