mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 21:49:24 +08:00
[jit] fix named tuples as attributes (#37251)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/37251 This was broken by recent changes to how we serialize with type tags. We save a name (like `Dict[str, MyNamedTuple]`) and then relied on the mobile type parser to resolve that name back into a set of types. This doesn't work for any NamedTypes as the mobile type parser doesn't know how to resolve those. The unpickler allows the caller to inject a type resolver in for this purpose, use that so that when importing in a non-mobile environment you get the right results. A second problem also had to be fixed: the SourceImporter type loader would only load named types directly (e.g. `MyNamedTuple`) and choked if it was a general type that contained a named tupe (e.g. `List[MyNamedTuple]`). Fixed that and renamed `loadNamedType` to `loadType` for clarity. Test Plan: Imported from OSS Differential Revision: D21235213 Pulled By: suo fbshipit-source-id: 16db0f4c5e91a890d67a8687cc8ababa6b94b0f4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
47c4dca1ab
commit
1f08ff12ec
@ -41,7 +41,7 @@ static void import_libs(
|
||||
&tensor_table,
|
||||
[&](const std::string& name) -> std::shared_ptr<Source> { return src; },
|
||||
/*version=*/2);
|
||||
si.loadNamedType(QualifiedName(class_name));
|
||||
si.loadType(QualifiedName(class_name));
|
||||
}
|
||||
|
||||
void testModuleInterfaceSerialization() {
|
||||
|
Reference in New Issue
Block a user