-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[JIT] Add Support For Module Containers as Iterables #28255
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
[ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27790 [ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27790 [ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
zdevito
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.
This looks pretty good. I have one substantive comment: that we should try just putting the iteration functionality into sugaredvalue, as a way of avoiding having to introduce a new concept.
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
zdevito
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.
This looks good. The two substantive comments are: avoid using more constant prop than we were before for ranges, and lets make statically determined lengths also the same as when we unroll loops to avoid introducing an exponential number of cases to handle.
| namespace torch { | ||
| namespace jit { | ||
|
|
||
| c10::optional<Stack> tryConstantPropNode(const Node* node) { |
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.
This is missing all of constant props checks that the node itself can be constant-propagated. Doesn't seem safe to use.
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.
It seems like this method is actually use as runNodeIfInputsAreConstant which has a different implicit contract. Should document what this will do. What is Print(4) expected to do here?
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And #27401 and #27506 [ghstack-poisoned]
Summary: Pull Request resolved: pytorch/pytorch#28255 Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables. As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length. Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list. Fix for #17179 And pytorch/pytorch#27401 and pytorch/pytorch#27506 Test Plan: Imported from OSS Reviewed By: ZolotukhinM Differential Revision: D18278124 Pulled By: eellison fbshipit-source-id: aca336a5b8da89c756b1f0884883649510cbde3c
Stack from ghstack:
Add support for treating Sequentials, ModuleLists, and ModuleDicts as iterables.
As previously, when emitting a for loop over a Module Container we unroll the for loop over all elements. We require that any Sugared Value in an iterable with a Module Container have a statically - determinable length.
Otherwise, if you zipped over a list of varying length and an nn.Sequential that alternated between returning a Tensor and a Dictionary, the output type would change based on the length of the list.
Fix for #17179
And #27401
and #27506