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

Switch from register_full_backward_hooks to tensor hooks #979

Closed
wants to merge 11 commits into from

Conversation

vivekmig
Copy link
Contributor

This switches usage of full backward hooks to instead apply forward hooks which then add tensor backward hooks, as suggested in #914 . We initially did not choose this approach since it may have limitations with backward hooks on modules with multiple tensors as inputs / outputs (each tensor must be called independently in the hook), but all current use-cases within Captum only require a single tensor input / output.

This change allows us to enable in-place modules as well as remove the limitation on neuron input attribution. DeepLift also no longer needs valid module checks, as these are no longer applicable with usage of tensor hooks.

Copy link
Contributor

@NarineK NarineK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this PR, @vivekmig! Looks much cleaner now, especially DeepLift.

Added couple questions and minor comments.

captum/_utils/common.py Outdated Show resolved Hide resolved
captum/_utils/common.py Show resolved Hide resolved
captum/_utils/common.py Show resolved Hide resolved
captum/_utils/gradient.py Outdated Show resolved Hide resolved
captum/attr/_utils/lrp_rules.py Show resolved Hide resolved
captum/attr/_utils/lrp_rules.py Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@vivekmig has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@vivekmig has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@vivekmig merged this pull request in 288cd3a.

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

Successfully merging this pull request may close these issues.

None yet

3 participants