richard:

tensor.detach() creates a tensor that shares storage with tensor that does not require grad.


I am trying to understand what “shares storage means”. Does that mean if I detach a tensor from it’s original but then opt.step() to modify the original, then Both would change?
i.e.
a = torch.tensor([1,2,3.], requires_grad=True)
b = a.detach()
opt = optim.Adam(a,lr=0.01)
a.backward()
opt.step() # changes both because they share storage?

So both change because they share storage? That seems an odd semantics to have or I am missing the point of .detach().

here is the migration guide Richard mentioned:

  
      
      pytorch.org
  
  
    

PyTorch 3

An open source deep learning platform that provides a seamless path from research prototyping to production deployment.


  
  
    
    
  
  



Related useful links:

https://stackoverflow.com/questions/55266154/pytorch-preferred-way-to-copy-a-tensor 4
Difference between detach().clone() and clone().detach() 9