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

[JIT] Add support for named_modules() #29495

Closed
wants to merge 8 commits into from

Conversation

eellison
Copy link
Contributor

@eellison eellison commented Nov 9, 2019

Stack from ghstack:

Fix for #28998

Differential Revision: D18412561

@eellison eellison requested a review from suo November 9, 2019 00:48
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Nov 9, 2019
…quential"


This PR adds support for `_modules`, making it so we no longer need to special case support for `nn.Sequential`. I was getting internal errors around the previous approach using `self.define()`, so i am adding this PR as part of the stack.

Fix for #28998

[ghstack-poisoned]
eellison pushed a commit that referenced this pull request Nov 9, 2019
ghstack-source-id: 5329963937c5622a691a9573bb95bac9597cc4af
Pull Request resolved: #29495
@eellison eellison requested review from zdevito, driazati and wanchaol and removed request for zdevito November 9, 2019 00:53
iterator->addChild(loc, m, modules_);
return std::make_shared<ModuleDictMethod>(iterator, "items");
} else {
throw ErrorReport(loc) << "_Modules only supports keys, values, or items";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_Modules -> _modules

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binding a private python member into TorchScript seems like the wrong approach. Shouldn't we implement the standard nn.Module API for this stuff? That would be the children, named_children, modules() and named_modules methods. Having _modules without named_children is going to promote the use of a private API.

…quential"


This PR adds support for `_modules`, making it so we no longer need to special case support for `nn.Sequential`. I was getting internal errors around the previous approach using `self.define()`, so i am adding this PR as part of the stack.

Fix for #28998

Differential Revision: [D18412561](https://our.internmc.facebook.com/intern/diff/D18412561)

[ghstack-poisoned]
eellison pushed a commit that referenced this pull request Nov 12, 2019
ghstack-source-id: 3a48515779883739cacde1f244d474884cfebc88
Pull Request resolved: #29495
…quential"


This PR adds support for `_modules`, making it so we no longer need to special case support for `nn.Sequential`. I was getting internal errors around the previous approach using `self.define()`, so i am adding this PR as part of the stack.

Fix for #28998

Differential Revision: [D18412561](https://our.internmc.facebook.com/intern/diff/D18412561)

[ghstack-poisoned]
…quential"


This PR adds support for `_modules`, making it so we no longer need to special case support for `nn.Sequential`. I was getting internal errors around the previous approach using `self.define()`, so i am adding this PR as part of the stack.

Fix for #28998

Differential Revision: [D18412561](https://our.internmc.facebook.com/intern/diff/D18412561)

[ghstack-poisoned]
eellison pushed a commit that referenced this pull request Nov 12, 2019
ghstack-source-id: 90941b7813c3f03ca0a63755cc42f6da9f32bf81
Pull Request resolved: #29495
…quential"


This PR adds support for `_modules`, making it so we no longer need to special case support for `nn.Sequential`. I was getting internal errors around the previous approach using `self.define()`, so i am adding this PR as part of the stack.

Fix for #28998

Differential Revision: [D18412561](https://our.internmc.facebook.com/intern/diff/D18412561)

[ghstack-poisoned]
@eellison eellison changed the title add support for _modules, reducing special casing of nn.Sequential [JIT] Add support for named_modules() Feb 25, 2020
@dr-ci
Copy link

dr-ci bot commented Feb 25, 2020

💊 CircleCI build failures summary and remediations

As of commit 01e28fe:

  • 1/1 failures introduced in this PR

Detailed failure analysis

One may explore the probable reasons each build failed interactively on the Dr. CI website.

🕵️ 1 new failure recognized by patterns

The following build failures do not appear to be due to upstream breakage:

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_build (1/1)

Step: "Build" (full log | pattern match details)

Automatic merge failed; fix conflicts and then commit the result.
CONFLICT (add/add): Merge conflict in .circleci/scripts/vs_install.ps1 
Auto-merging .circleci/scripts/vs_install.ps1 
CONFLICT (add/add): Merge conflict in .circleci/scripts/binary_run_in_docker.sh 
Auto-merging .circleci/scripts/binary_run_in_docker.sh 
CONFLICT (add/add): Merge conflict in .circleci/scripts/binary_populate_env.sh 
Auto-merging .circleci/scripts/binary_populate_env.sh 
CONFLICT (add/add): Merge conflict in .circleci/scripts/binary_ios_upload.sh 
Auto-merging .circleci/scripts/binary_ios_upload.sh 
CONFLICT (add/add): Merge conflict in .circleci/config.yml 
Auto-merging .circleci/config.yml 
Automatic merge failed; fix conflicts and then commit the result. 

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 on the GitHub issue tracker.

This comment has been revised 19 times.

@eellison eellison dismissed zdevito’s stale review February 25, 2020 19:50

no longer exposing internal api, now exposing named_modules()

@eellison
Copy link
Contributor Author

This doesn't do the checking for uniqueness, but when we recursively script we create a new module on each compilation (don't preserve aliasing), so i don't think that's actually a problem.

eellison pushed a commit that referenced this pull request Feb 25, 2020
ghstack-source-id: 0bc3f1a98042f67c41baae297d4ff70d55a07bc7
Pull Request resolved: #29495
Copy link
Contributor

@driazati driazati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a follow up issue or add to this PR stuff like named_children?

torch/csrc/jit/script/python_sugared_value.h Outdated Show resolved Hide resolved
torch/csrc/jit/script/python_sugared_value.cpp Outdated Show resolved Hide resolved
@eellison
Copy link
Contributor Author

Can you make a follow up issue or add to this PR stuff like named_children?

i'm going to do the other apis as a follow up sometime this week.

eellison pushed a commit that referenced this pull request Feb 26, 2020
ghstack-source-id: 488beb0a820c3b7cd3e4f09443e849aed4f4ba39
Pull Request resolved: #29495
@facebook-github-bot
Copy link
Contributor

@eellison merged this pull request in 057fd5e.

hczhu pushed a commit that referenced this pull request Feb 28, 2020
…29495)

Summary:
Pull Request resolved: #29495

This PR adds support for `_modules`, making it so we no longer need to special case support for `nn.Sequential`. I was getting internal errors around the previous approach using `self.define()`, so i am adding this PR as part of the stack.

Fix for #28998

Test Plan: Imported from OSS

Differential Revision: D18412561

Pulled By: eellison

fbshipit-source-id: a8b24ebee39638fccf63b2701f65f8bb0de84faa
@facebook-github-bot facebook-github-bot deleted the gh/eellison/28/head branch March 1, 2020 15:17
ttumiel pushed a commit to ttumiel/pytorch that referenced this pull request Mar 4, 2020
…ytorch#29495)

Summary:
Pull Request resolved: pytorch#29495

This PR adds support for `_modules`, making it so we no longer need to special case support for `nn.Sequential`. I was getting internal errors around the previous approach using `self.define()`, so i am adding this PR as part of the stack.

Fix for pytorch#28998

Test Plan: Imported from OSS

Differential Revision: D18412561

Pulled By: eellison

fbshipit-source-id: a8b24ebee39638fccf63b2701f65f8bb0de84faa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants