Add register_module alias to nn.Module#65174
Add register_module alias to nn.Module#65174rodrigoberriel wants to merge 4 commits intopytorch:masterfrom
Conversation
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit f338a49 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
jbschlosser
left a comment
There was a problem hiding this comment.
Fixes #60397. I'm not sure how aliases are supposed to be implemented, but this is the most basic/direct way, IMO. As a side-effect, this implementation results in a "duplicate" doc entry, inheriting the one from
add_module:
I think this way looks good and it's nice that the docs are inherited.
Questions:
- Should I replicate the tests? There are two for
add_module: test_add_module_raises_error_if_attr_exists and test_add_module.
Rather than duplicating the tests, maybe they could be slightly expanded to iterate over the two aliased functions with the the same test logic.
- This PR only adds
register_moduletonn.Module. There is anadd_modulein_RemoteModule, which raisesNotSupported, and there is another one inConcreteModuleTypeBuilder, which means something else, I think. Should I do anything about them?
cc @pritamdamania for _RemoteModule. I may be wrong, but I don't think you need to touch ConcreteModuleTypeBuilder since the add_module there is unrelated.
|
I think you should do the alternative impl, for 2 reasons:
^Just my 2 cents. I'll let others decide! |
|
I agree with @ssnl w.r.t. the implementation. I changed to the alternative, because although @jbschlosser showed support for the current one, he didn't say anything against the alternative :) Please, let me know if I should actually keep the current impl. @jbschlosser I modified the tests to iterate over the aliases, but I'm not sure if this impl is what you were expecting. As far as I understood, as |
Codecov Report
@@ Coverage Diff @@
## master #65174 +/- ##
==========================================
+ Coverage 66.37% 66.39% +0.02%
==========================================
Files 732 735 +3
Lines 93616 94047 +431
==========================================
+ Hits 62135 62445 +310
- Misses 31481 31602 +121 |
Cool, I'm good with the alternative as well.
Looks good! |
|
@jbschlosser has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
@jbschlosser merged this pull request in b80bdcc. |
Fixes #60397. I'm not sure how aliases are supposed to be implemented, but this is the most basic/direct way, IMO. As a side-effect, this implementation results in a "duplicate" doc entry, inheriting the one from
add_module:An alternative implementation could be:
which results in this documentation:
Questions:
add_module: test_add_module_raises_error_if_attr_exists and test_add_module.register_moduletonn.Module. There is anadd_modulein_RemoteModule, which raisesNotSupported, and there is another one inConcreteModuleTypeBuilder, which means something else, I think. Should I do anything about them?cc @ngimel @ssnl