galactica147:

Could you elaborate a bit what indices -= indices.min(dim=1, keepdims=True)[0] is doing?


See,
indices = [[0, 0, 1, 1, 1],
           [2, 2, 3, 3, 4]]

But here scatter needs col index.
indices = [[0, 0, 1, 1, 1],
           [0, 0, 1, 1, 2]]




 galactica147:

I wonder if there is any in-place way that can save the extra memory cost.


I have no idea now.