I run the code:
y = t[0, :] 
y += 1
print(y)
print(t[0, :]) 

the result is :
tensor([5, 9, 9])
tensor([5, 9, 9])

y and t[0,:] share memory. But after I changed the index, I run the new code:
y = t[0, [1, 2]]
y += 1
print(y)
print(t[0, [1, 2]]) 

the result is:
tensor([10, 10])
tensor([9, 9])

y and t[0, [1, 2] don’t share memory。Do you know the reason? Any help would be appreciated, thank you.