Rancho_Xia:

Is there something that I’ve missed?


You would have to check if the manipulated tensor is needed in its original form for the gradient calculation, which disallows inplace operations on it.
This post 4 shows you a simple example.