-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add flag to temporarily enable first class modules #21272
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
Summary: this flag is used in tests to enable first-class module execution so that we can test things like invoking methods on first-class modules and setting their properties before we implement all the parts necessary to remove the old execution pattern.
Add flag to temporarily enable first class modules Summary: this flag is used in tests to enable first-class module execution so that we can test things like invoking methods on first-class modules and setting their properties before we implement all the parts necessary to remove the old execution pattern. gh-metadata: pytorch pytorch 21272 gh/zdevito/46/head
Add flag to temporarily enable first class modules Summary: this flag is used in tests to enable first-class module execution so that we can test things like invoking methods on first-class modules and setting their properties before we implement all the parts necessary to remove the old execution pattern. gh-metadata: pytorch pytorch 21272 gh/zdevito/46/head
Krovatkin
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.
![]()
| foo = Foo() | ||
| input = torch.rand(3, 4) | ||
| foo.forward(input) | ||
| self.assertEqual(input, foo.foo) |
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.
nitpick: foo.bar might be a little bit more readable
|
|
||
| IValue Method::operator()(std::vector<IValue> stack, const Kwargs& kwargs) { | ||
| getSchema().checkAndNormalizeInputs(stack, kwargs); | ||
| if (experimental_run_as_first_class) { |
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.
nitpick: this logic (pushing module and parameters onto a stack) seems to be duplicated across run and (). Maybe we should consider refactoring it into a helper, otherwise we might forget to update one of the places eventually?
|
|
||
| struct TORCH_API Method { | ||
| Method(Module* owner, Function* function); | ||
| Method(Module* owner, const std::shared_ptr<Function>& function); |
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.
so someone else now owns a function aside from Method?
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.
for now yes, Michael is working on our final state for Function ownership which will make this stuff more clear.
Add flag to temporarily enable first class modules Summary: this flag is used in tests to enable first-class module execution so that we can test things like invoking methods on first-class modules and setting their properties before we implement all the parts necessary to remove the old execution pattern. gh-metadata: pytorch pytorch 21272 gh/zdevito/46/head
Add flag to temporarily enable first class modules Summary: this flag is used in tests to enable first-class module execution so that we can test things like invoking methods on first-class modules and setting their properties before we implement all the parts necessary to remove the old execution pattern. gh-metadata: pytorch pytorch 21272 gh/zdevito/46/head
Add flag to temporarily enable first class modules Summary: this flag is used in tests to enable first-class module execution so that we can test things like invoking methods on first-class modules and setting their properties before we implement all the parts necessary to remove the old execution pattern. gh-metadata: pytorch pytorch 21272 gh/zdevito/46/head
Stack from ghstack:
Summary: this flag is used in tests to enable first-class module
execution so that we can test things like invoking methods on
first-class modules and setting their properties before we implement
all the parts necessary to remove the old execution pattern.
Differential Revision: D15600068