Hi! I have a multidimensional Tensor (4 or more dimensions) and I want to assign data to it based on given indices.
E.g. in the tensor mem I want to modify the 6 rows (3 rows of each dimension 0) with the indices indices and their final value must be the one given by the 6 rows on values.:
mem = torch.zeros(2,4,5,6) # size -> (2,4,5,6)
indices = torch.Tensor([[[0, 0],[0, 1],[2, 1]], # size -> (2,3,2)
[[1, 0],[0, 0],[2, 0]]]).long()
values = torch.arange(1,2*3*6+1).reshape(2,3,6) # size -> (2,3,6)
mem.index_add(0, indices, values)
However, I find the following error:
IndexError: index_add_(): Index is supposed to be a vector
How can I address this problem when using Tensor with 4 or more dimensions?
Note that both indices and values share the first two dimension sizes, and the last dimension of the values correspond to the last dimension of the mem Tensor.
Thank you in advance.