There’s a reported issue with random_
when the lower bound is negative for cuda.LongTensor
s. However those large numbers seem to be valid indices.
>>> x1 = torch.linspace(1, 10, 10).cuda();
>>> x2 = torch.linspace(21, 30, 10).cuda();
>>> torch.stack((x1, x2))
1 2 3 4 5 6 7 8 9 10
21 22 23 24 25 26 27 28 29 30
[torch.cuda.FloatTensor of size 2x10 (GPU 0)]
>>> idx = torch.cuda.LongTensor(3).random_(-10, 0).add_(10); idx
4.2950e+09
4.2950e+09
4.2950e+09
[torch.cuda.LongTensor of size 3 (GPU 0)]
>>> torch.stack([x1[idx], x2[idx]])
3 5 2
23 25 22
[torch.cuda.FloatTensor of size 2x3 (GPU 0)]
Is it safe to use those numbers for indexing?