-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Jit pre save hook #38186
Jit pre save hook #38186
Conversation
1. Added pre_save_hooks features to jit.save. 2. Added related unittests
Thanks for your contribution! |
python/paddle/fluid/dygraph/jit.py
Outdated
remove_save_pre_hook(self._hook) | ||
|
||
|
||
def register_save_pre_hook(hook): |
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 should append api doc like other api
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.
Done, added api doc to public functions.
python/paddle/fluid/dygraph/jit.py
Outdated
return HookRemoveHelper(hook) | ||
|
||
|
||
def remove_save_pre_hook(hook): |
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.
if remove_save_pre_hook
is not used as public api, we recommoned nameing it with prefix _
, _remove_save_pre_hook
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.
Done, renamed remove_save_pre_hook
to _remove_save_pre_hook
python/paddle/fluid/dygraph/jit.py
Outdated
_save_pre_hooks_lock.release() | ||
|
||
|
||
def clear_save_pre_hooks(): |
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.
clear_save_pre_hooks
used in what cases? Is HookRemoveHelper.remove
enough?
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.
Currently not, but this is a convenient API to let user clear all hooks in one call.
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.
If the specific usage scenario is not clear, we recommended to use it as an internal method first, and then upgrade it to a public API if necessary in the future
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.
Done, currently rename clear_pre_save_hooks
with prefix _
and make it internal use only.
python/paddle/fluid/dygraph/jit.py
Outdated
_save_pre_hooks_lock.release() | ||
|
||
|
||
def run_save_pre_hooks(func): |
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.
same as _remove_save_pre_hook
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.
Done
3228be7
to
4677f6e
Compare
Sorry to inform you that 4677f6e's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
… jit_pre_save_hook
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.
LGTM
PR types
New features
PR changes
APIs
Describe
Pre-saving Hooks in
paddle.jit.save
nn.Layer
beforejit.save
.Usage Example: