I have a tensor x and x.shape=(batch_size,10)
I want to add one to all of the elements, and take two different operations
(1) x=x+1
(2) for i in range(0,batch_size):
x[i]=x[i]+1
I got the same tensors with the two operations,but when I call loss.backward(), (2) takes much more time than (1) in back propagation. What’s the difference betweent them???