I can change the value of a tensor that requires grad without autograd knowing about it:
def error_unexpected_way_to_by_pass_safety():
import torch
a = torch.tensor([1,2,3.], requires_grad=True)
# are detached tensor's leafs? yes they are
a_detached = a.detach()
#a.fill_(2) # illegal, warns you that a tensor which requires grads is used in an inplace op (so it won't be recorded in computation graph so it wont take the right derivative of the forward path as this op won't be in it)
a_detached.fill_(2) # weird that this one is allowed, seems to allow me to bypass the error check from the previous comment...?!
print(f'a = {a}')
print(f'a_detached = {a_detached}')
a.sum().backward()
this throws no errors. Though, I am able to change the contents of a
which is a tensor that requires grad without autograd knowing about. Which means the computation graph does not know about this op (filling with 2). This seems wrong. Can anyone shed light what is going on?