Hello there,
the following code reproduces my problem. I want to access a tensor with labels randomly and stumbled across the problem of retrieving inconsistent results when using :index() as access method.
require 'cutorch'
i = torch.LongTensor(3)
i[{1}] = 7816227
i[{2}] = 19206839
i[{3}] = 19206840
torch.manualSeed(101)
labels = torch.Tensor(19206840)
labels = labels:random(1,257)
print(tostring(labels:index(1, i)))
print(tostring(labels[i[{1}]]) .. ' ' .. tostring(labels[i[{2}]]) .. ' ' ..tostring(labels[i[{3}]]))
labels = labels:cuda()
print(tostring(labels:index(1, i)))
print(tostring(labels[i[{1}]]) .. ' ' .. tostring(labels[i[{2}]]) .. ' ' ..tostring(labels[i[{3}]]))
I expect lines 9 and 12 to produce the same results. but they dont. I get 171, 46, 139 before moving labels to the CUDA device and 171, 13, 13 afterwards in line 12. Interestingly the other access method works fine.