Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

@zdevito
Copy link
Contributor

zdevito commented May 14, 2019

Stack from ghstack:

  • #20503 Allow static inheritence for ScriptModules

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

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
@pytorchbot pytorchbot added the jit label May 14, 2019
@zdevito zdevito requested a review from eellison May 14, 2019
Copy link
Contributor

eellison left a comment

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.

v = torch.rand(3, 4)
b = B()
self.assertEqual(b(v), v + v * v)
>>>>>>> Allow static inheritence for ScriptModules

This comment has been minimized.

Copy link
@eellison

eellison May 14, 2019

Contributor

looks like merge error here

@justusschock justusschock referenced this pull request May 15, 2019
9 of 10 tasks complete
@TheCodez

This comment has been minimized.

Copy link
Contributor

TheCodez commented May 15, 2019

Is it possible to call the super class forward method in the derived class forward method?

@zdevito

This comment has been minimized.

Copy link
Contributor Author

zdevito commented May 15, 2019

super is not support and it will take some time before we can support it.

@zou3519 zou3519 deleted the gh/zdevito/37/head branch May 15, 2019
@facebook-github-bot

This comment has been minimized.

Copy link
Contributor

facebook-github-bot commented May 15, 2019

@zdevito merged this pull request in 5243fe0.

1 similar comment
@facebook-github-bot

This comment has been minimized.

Copy link
Contributor

facebook-github-bot commented May 15, 2019

@zdevito merged this pull request in 5243fe0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.