🐛 Bug
different behavior of slicing tensor with slices in different tensor type
To Reproduce
Steps to reproduce the behavior:
import torch
a = torch.randint(low=1, high=10, size=(2, 3))
print(a)
b = torch.randint(2, (3,), dtype=torch.uint8)
print(b)
a[0, b] = 0
print(a)
Expected behavior
if dtype of b is torch.uint8, it works normally like:
tensor([[9, 5, 3],
[1, 3, 9]])
tensor([1, 0, 1], dtype=torch.uint8)
tensor([[0, 5, 0],
[1, 3, 9]])
if I change dtype to torch.int64, it woks differently like:
tensor([[3, 9, 9],
[8, 7, 7]])
tensor([1, 0, 1])
tensor([[0, 0, 9],
[8, 7, 7]])
it seems that the value of slices act as slices instead of the position of no-zero elements
Environment
- PyTorch Version (e.g., 1.0): 1.1.0
- OS (e.g., Linux): Mac os 10.14.3
- How you installed PyTorch (
conda, pip, source): pip
- Build command you used (if compiling from source):
- Python version: 3.6
- CUDA/cuDNN version: None
- GPU models and configuration: None
- Any other relevant information: None
Additional context
🐛 Bug
different behavior of slicing tensor with slices in different tensor type
To Reproduce
Steps to reproduce the behavior:
Expected behavior
if dtype of b is torch.uint8, it works normally like:
if I change dtype to torch.int64, it woks differently like:
it seems that the value of slices act as slices instead of the position of no-zero elements
Environment
conda,pip, source): pipAdditional context