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
Allow static inheritence for ScriptModules #20503
Conversation
Summary: Previously, we registered script modules of parent classes during their init methods, making it impossible to correctly 'override' a method or leave it blank in a subclass. This diff adds the functionality by waiting until the child init is finished before registering all the methods. Test Plan: python test/test_jit.py
Looks good!
Could you add a test for a module inheritance hierarchy of 3 ? It's not clear to me that we're currently iterating through bases in the right order, since the current test only has a single base.
test/test_jit.py
Outdated
v = torch.rand(3, 4) | ||
b = B() | ||
self.assertEqual(b(v), v + v * v) | ||
>>>>>>> Allow static inheritence for ScriptModules |
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 like merge error here
Is it possible to call the super class forward method in the derived class forward method? |
super is not support and it will take some time before we can support it. |
Stack from ghstack:
Summary: Previously, we registered script modules of parent classes during their init methods, making it impossible
to correctly 'override' a method or leave it blank in a subclass. This diff adds the functionality by waiting
until the child init is finished before registering all the methods.
Test Plan: python test/test_jit.py
Differential Revision: D15341555