Hello,
In my code I need to do something like this
. . .
# a (n_a, n_features)
# b (n_b, n_features)
# some_indices (n_a,) long
result = b.clone()
result[some_indices, :] = a
return result
Will this propagate gradients correctly for a
and b
?
(ie the gradient of result
for some_indices
propagated to a
, and for all the other indices, they are propagated to b
)
I am a bit scared of the inplace operation, I couldn’t find explanations of where they’re safe or not for the autograd engine.
Usually I would use a torch.where
, but a
doesn’t have the same shape as b, so that would require me to get a
to that same size, which would also require an assignment…
Thank you for the help