I have a tensor A, a tensor B and a index tensor C
for example:
A = [[1, 2, 3], [4, 5, 6]]
B = [[10, 20, 30], [40, 50, 60]]
C = [0, 0]
I would like to use B to update A,
A[C[0]] += B[0]
A[C[1]] += B[1]
So far, I am using for loop to achieve this, which is very slow. The for loop snippet is
for i, c_i in enumerate (C ):
A[c_i] += B[i]
Any suggestions on how to get rid of for loop or speed up the implementation. Thanks a lot. The above is just a simplified version and in practice, the A and B tensors are very large.