I’d like to check if one tensor is anywhere in the autograd history of another tensor. Is this possible?
Use case: I’m calling torch.autograd.grad on both tensors, and want to avoid double-counting the gradient on the tensor that’s further back in the history. My proposed fix is to (before the forward pass) check if one tensor is in the history of the other, and if it is, transform it through an identity (x = x.view(*x.shape)).