Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute only the required gradients in the backward pass #31

Open
tvercaut opened this issue Dec 14, 2022 · 0 comments
Open

Compute only the required gradients in the backward pass #31

tvercaut opened this issue Dec 14, 2022 · 0 comments

Comments

@tvercaut
Copy link
Member

Currenly if A and B are inputs, we always compute the gradient with respect to both A and B in the backward pass irrespective of whether this is requested by the caller.

As shown in the extending pytorch example
https://pytorch.org/docs/stable/notes/extending.html#example
we should make use of a pattern invoving

if ctx.needs_input_grad[i]:

to avoid unnecessary computation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant