Commit Graph

2 Commits

Author SHA1 Message Date
Michael Suo
afa25c77f1 [package] Make it possible to re-save a PackageImporter module (#65101)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65101

As title. Previously this was guarded against for implementation
simplicity, as we didn't really think there was a use case for saving a
mangled module name directly.

But people started doing stuff like:
```
exporter.save_module(my_imported_obj.__module__)
```
which implicitly passes along the mangled module name.

This PR makes it so that given `PackageImporter` instance can always
import modules that it created, and changes `PackageExporter` to
properly demangle the resulting module name when writing the package to
the export archive.

Differential Revision:
D30975712
D30975712

Test Plan: Imported from OSS

Pulled By: suo

fbshipit-source-id: d9e849bf651713890e72dccdcef74fa52d377149
2021-09-17 16:25:11 -07:00
Michael Suo
0b49778666 [package] mangle imported module names (#50049)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50049

Rationale and implementation immortalized in a big comment in
`torch/package/mangling.md`.

This change also allows imported modules to be TorchScripted

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D25758625

Pulled By: suo

fbshipit-source-id: 77a99dd2024c76716cfa6e59c3855ed590efda8b
2021-01-13 16:32:36 -08:00