Some in-place operations work with autograd?

The following example does not result in an autograd error:

lin = nn.Linear(2,2)
y = lin(torch.rand(2))
y[1] = 0 # in-place operation
y.sum().backward()

I’m just curious, how come this works? When, in general, do in-place operations not interfere with autograd? Thanks!

Hi Archie!

Here is a post with some examples that illustrate when inplace operations
will and won’t break autograd:

Best.

K. Frank