Solved by albanD in post #2 
              
              
                Hi, 
The first one should never be used as .data should not be used. 
The new api for #1 is: 
with torch.no_grad():
    x.copy_(k)

And the difference is clearer: use #1 (EDIT: the version of #1 given just above in my comment, not your original one) if the copy should not be tracked by the autograd …