Hi,
Simple problem, which is already solved in numpy with add.at operator. I want to index with repeating indices over two dimensions. A simple 1D example :
l=torch.ones(5)
i = torch.LongTensor([1, 2, 2, 3])
l[i] += 1
print(l)
Out[52]: 

 1
 2
 2 # should be 3
 2
 1
[torch.FloatTensor of size 5]

If you need to think of a real use case :
# l_ij = 1 with i from m1 and j from m2
l = torch.autograd.Variable(torch.LongTensor(10, 10))
m1 = torch.LongTensor(1, 255, 255).random_(0, 10)
m2 = torch.LongTensor(1, 255, 255).random_(0, 10)
l[m1, m2] = 1

This kind of indexing does not work because there are repeated indices in both index tensors. @Soumith_Chintala pointed me to index_add_ which seems in fact to solve part of the problem with indexing, however I can’t think of a solution comparable to the one of numpy https://stackoverflow.com/questions/46114340/numpy-advanced-indexing-same-index-used-multiple-times-in 29.
Thanks