Hi,
I am trying to understand how torch.autograd.grad work. My understanding of how Pytorch performs differentiation is that each tensor is associated with a grad_fn that describes how the current tensor is derived from other tensors. If we were to write our custom functions in pytorch, we need to inherit from Function and implement the forward and backward functions. During the forward pass, we will need to use the ctx_manager to cache the inputs (and other relevant information) for the backward pass.
My question is if we are already caching the inputs in ctx_manager, why do we still need to provide inputs in torch.autograd.grad?
Thank you in advance for your help