-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[JIT] NamedTuple serialization #21839
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
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
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. Let's coordinate a few things tomorrow morning to make sure it works for both Interfaces and NamedTuples
torch/csrc/jit/import_source.cpp
Outdated
| auto fullName = c10::QualifiedName(basename_, name); | ||
| if (auto classType = cu_.get_class(fullName)) { | ||
| return std::make_shared<ClassValue>(classType); | ||
| if (auto serializable_type = cu_.get_serializable_type(fullName)) { |
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 going to conflict with #21853 which also needs to redefine how named types are put in the compilation unit.
torch/csrc/jit/import_source.cpp
Outdated
|
|
||
| TypePtr resolveType(const std::string& name, const SourceRange& loc) const override { | ||
| return lib_cu_.get_class(c10::QualifiedName(name)); | ||
| return lib_cu_.get_serializable_type(c10::QualifiedName(name)); |
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.
Yeah, we should coordinate how this will work across interfaces and named tuples, both require extending this API.
torch/csrc/jit/script/parser.cpp
Outdated
| L.reportError( | ||
| "Inheritance is not yet supported for TorchScript classes yet."); | ||
| // Only support inheriting from NamedTuple right now. | ||
| if (L.nextIf(TK_NAMED_TUPLE)) { |
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.
L.nextIf(TK_IDENT).value() == "NamedTuple"
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
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.
Looks good!
torch/csrc/jit/import_source.cpp
Outdated
| auto fullName = c10::QualifiedName(basename_, name); | ||
| if (auto classType = cu_.get_class(fullName)) { | ||
| return std::make_shared<ClassValue>(classType); | ||
| if (auto serializable_type = cu_.get_serializable_type(fullName)) { |
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.
get_serializabe_type -> get_type
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
[JIT] NamedTuple serialization gh-metadata: pytorch pytorch 21839 gh/jamesr66a/6/head
Summary: Pull Request resolved: pytorch/pytorch#21839 ghimport-source-id: b9d82018fbf26b22d58cad3a033cbfe4e879a8fe Test Plan: Imported from OSS Reviewed By: zdevito Differential Revision: D15860002 Pulled By: jamesr66a fbshipit-source-id: 0fc97c4adefa9ae4937f21179c7afa817f4099e5
|
@jamesr66a merged this pull request in dd046be. |
Stack from ghstack:
Differential Revision: D15860002