The following example does not result in an autograd error:
lin = nn.Linear(2,2)
y = lin(torch.rand(2))
y = 0 # in-place operation
I’m just curious, how come this works? When, in general, do in-place operations not interfere with autograd? Thanks!
Here is a post with some examples that illustrate when inplace operations
will and won’t break autograd: