pytorch/test/cpp
Michael Suo 1f08ff12ec [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
2020-04-24 17:48:44 -07:00
..
api Added autograd support for C->C functions and enabled requires_grad=True for complex (#36932) 2020-04-24 12:30:49 -07:00
common Trim libshm deps, move tempfile.h to c10 (#17019) 2019-02-13 19:38:35 -08:00
dist_autograd Fix/relax CMake linter rules (#35574) 2020-03-27 16:52:33 -07:00
jit [jit] fix named tuples as attributes (#37251) 2020-04-24 17:48:44 -07:00
rpc [rpc] Avoid wireDeserializer overreading buffers by 1 byte (#36976) 2020-04-21 17:01:45 -07:00
tensorexpr [TensorExpr] Cleanup TensorExprKernel class and add CPP tests for it. (#36952) 2020-04-23 10:51:33 -07:00
__init__.py Add train() / eval() / is_training() to C++ ScriptModule API (#16044) 2019-02-01 13:07:38 -08:00