-
Notifications
You must be signed in to change notification settings - Fork 492
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
Hook Removal #340
Hook Removal #340
Conversation
@NarineK Updated this PR, it should be ready for review now, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you! Couple suggestions.
- We could use try-finally and remove the hooks in the finally block once and avoid second remove for the normal case and except-raise-error blocks.
- It looks like here we might also need a try-finally block ?
https://github.com/pytorch/captum/blob/master/captum/attr/_utils/gradient.py#L240
read the documentation in test_config.py and add cases based on the | ||
schema described there. | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably also need to do try-finally for this one ?
https://github.com/pytorch/captum/blob/master/captum/attr/_utils/gradient.py#L240
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line is already updated above? But will switch from except to finally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thanks for the review!
|
Summary: This PR ensures that all hooks are removed, even if attribution raises an error while the hook is placed. Corresponding generated tests are also added, which simulate errors during runtime and verify that no hooks remain on the model after execution. Note that this PR depends on the generated tests, so code is included here as well, will resolve this once the updated tests PR is merged. Pull Request resolved: pytorch#340 Reviewed By: edward-io Differential Revision: D21020096 Pulled By: vivekmig fbshipit-source-id: 05efaf9021222318d3adf2b029592754d7c836e7
This PR ensures that all hooks are removed, even if attribution raises an error while the hook is placed. Corresponding generated tests are also added, which simulate errors during runtime and verify that no hooks remain on the model after execution.
Note that this PR depends on the generated tests, so code is included here as well, will resolve this once the updated tests PR is merged.