pytorch
3a385656 - [export] Initial serialization v2 (#102707)

Commit
2 years ago
[export] Initial serialization v2 (#102707) v2 of https://github.com/pytorch/pytorch/pull/102125 because of git issues corresponding deserialization diff: https://github.com/pytorch/pytorch/pull/102716 Implementing serialization of the exported program to a python dataclass, and then from that dataclass to json. This is split into a couple of sections: - `serialize(ep: ep.ExportedProgram, opset_version: Dict[str, int]) -> Tuple[bytes, bytes]` -- takes an exported program object, a dictionary mapping opset namespaces to versions, and returns the serialized exported program in bytes, and separately the state dict serialized in bytes - `GraphModuleSerializer` class that serializes torch.fx.GraphModule to the schema.GraphModule dataclass - `ExportedProgramSerializer` class that serializes torch._export.exported_program.ExportedProgram to the schema.ExportedProgram dataclass Serialization TODOs: - [x] pytree spec: https://github.com/pytorch/pytorch/pull/102577 - [ ] higher order ops - [ ] node metadata (specifically nn_module_stack/source_fn) - [ ] constraints - [ ] graph module metadata The tests are not super comprehensive, but that's because I think it'll be better tested + easier to test once deserialization is implemented. Pull Request resolved: https://github.com/pytorch/pytorch/pull/102707 Approved by: https://github.com/avikchaudhuri, https://github.com/zhxchen17
Author
Committer
Parents
Loading