-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Replace .get_model() with explicit .lightning_module #6035
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
Conversation
|
Hello @awaelchli! Thanks for updating this PR.
Comment last updated at 2021-02-18 13:55:19 UTC |
Codecov Report
@@ Coverage Diff @@
## master #6035 +/- ##
======================================
Coverage 93% 93%
======================================
Files 160 160
Lines 11367 11403 +36
======================================
+ Hits 10582 10620 +38
+ Misses 785 783 -2 |
tchaton
left a comment
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 !
Borda
left a comment
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.
are we keeping get_model or shall we deprecate it?
cc: @PyTorchLightning/core-contributors
+1 for deprecating |
|
Thank you for the reviews. I added the requested deprecation warning + test 74c55c4 |
| """Called at the end of fit and test""" | ||
| for callback in self.callbacks: | ||
| callback.teardown(self, self.get_model(), stage) | ||
| callback.teardown(self, self.lightning_module, stage) |
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.
do you want to move this outside of the loop to save on unwrapping per callback?
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 it's almost not worth it, because unwrapping doesn't really add any overhead since it's just following references, i.e., model.module in case of DDP for example.
I could be wrong, or it may change in the future. Do you see it as a big overhead?
What does this PR do?
Follow up to #5743
get_model() returns always the LightningModule
By using the lightning_module property getter, we make it explicit.
The old get_model() is still there. This is fully backward compatible.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃