see the picture blow:

image.png788×946 41.7 KB

where x, inds are re created by x=torch.rand(4, 2, 3), inds=torch.arange(4).view(4, 1, 1).expand(4, 2, 1) respectively.
however when I use x.gather(2, inds), error occurred:
RuntimeError: Invalid index in gather at /Users/soumith/b101_2/2019_02_08/wheel_build_dirs/wheel_3.7/pytorch/aten/src/TH/generic/THTensorEvenMoreMath.cpp:454

image.png1622×520 80.7 KB

my environment is on macOS high sierra 10.13.6, with python3.7, torch 1.0.1.post2.
Besides, I have tried the 2 order tensor:

image.png1632×532 85.3 KB

Is the tensor gathered must be a square?
And last, why the randint_like’s return still is torch.float type?

image.png950×568 69.6 KB

Thanks!