Repository: pytorch
Issue: No assertion when using scatter_ on a non-contiguous tensor
Labels: module: error checking,triaged,module: partial aliasing,module: scatter & gather ops

## 🐛 Bug

Don't know if I should call it a bug, but I think it is better if you could add an assertion if people use scatter_ on a non-contiguous tensor, since the scatter_ function will behave unexpectedly in this case. In other words, the output of scatter_ for a non-contiguous tensor is different from its output for an "equivalent" contiguous tensor.

## To Reproduce

Steps to reproduce the behavior:

Run the code sample and observe the values of z1 and z2. They are different, but users tend to think they are the same. Better add an assertion if user use scatter_ on z2.

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior

```
import torch
x = torch.rand(2, 5)

y1 = torch.zeros(3, 5)
y2 = torch.zeros(1, 5).expand(3,-1)

z1 = y1.scatter_(0, torch.tensor([[0, 1, 2, 0, 0], [2, 0, 0, 1, 2]]), x)
z2 = y2.scatter_(0, torch.tensor([[0, 1, 2, 0, 0], [2, 0, 0, 1, 2]]), x)

print(z1)
print(z2)
print(z1-z2)
```

output:

```
tensor([[0.3873, 0.7741, 0.0770, 0.6895, 0.3309],
        [0.0000, 0.8596, 0.0000, 0.3726, 0.0000],
        [0.3587, 0.0000, 0.7394, 0.0000, 0.6455]])
tensor([[0.3587, 0.7741, 0.0770, 0.3726, 0.6455],
        [0.3587, 0.7741, 0.0770, 0.3726, 0.6455],
        [0.3587, 0.7741, 0.0770, 0.3726, 0.6455]])
tensor([[ 0.0286,  0.0000,  0.0000,  0.3169, -0.3145],
        [-0.3587,  0.0854, -0.0770,  0.0000, -0.6455],
        [ 0.0000, -0.7741,  0.6624, -0.3726,  0.0000]])
```

## Environment

PyTorch version: 1.1.0
Is debug build: No
CUDA used to build PyTorch: 10.0.130

OS: Ubuntu 16.04.6 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
CMake version: Could not collect

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: Tesla P100-PCIE-16GB
GPU 1: Tesla P100-PCIE-16GB
GPU 2: Tesla P100-PCIE-16GB
GPU 3: Tesla P100-PCIE-16GB

Nvidia driver version: 418.67
cuDNN version: Could not collect

Versions of relevant libraries:
[pip] numpy==1.16.2
[pip] numpydoc==0.8.0
[pip] torch==1.1.0
[pip] torchtext==0.1.1
[pip] torchvision==0.3.0
[conda] blas                      1.0                         mkl  
[conda] mkl                       2019.3                      199  
[conda] mkl-service               1.1.2            py37he904b0f_5  
[conda] mkl_fft                   1.0.10           py37ha843d7b_0  
[conda] mkl_random                1.0.2            py37hd81dba3_0  
[conda] pytorch                   1.1.0           py3.7_cuda10.0.130_cudnn7.5.1_0    pytorch
[conda] torchtext                 0.1.1                    pypi_0    pypi
[conda] torchvision               0.3.0           py37_cu10.0.130_1    pytorch

 - PyTorch Version (e.g., 1.0):
 - OS (e.g., Linux):
 - How you installed PyTorch (`conda`, `pip`, source):
 - Build command you used (if compiling from source):
 - Python version:
 - CUDA/cuDNN version:
 - GPU models and configuration:
 - Any other relevant information:

## Additional context

<!-- Add any other context about the problem here. -->