I need to perform an index_add operation on 3D tensors, however, this operation is only implemented for 2D tensors and the indices needs to be a vector. I have been trying to think of a workaround which achieves the same but with no success. I would be glad if I could get some help!
My input tensor has the following shape (batch_size, max_length, emb_dim) and my index is of size (batch_size, max_length). I want to add vectors from the input tensor to itself along dim=1 based on the index values. For example, index[0, 1] = 3 will mean input[0, 1] and input[0, 3] are to be added.