TorchScript + ONNX

Back when PyTorch 1.0 was announced, there was this little mention of @script annotations and ONNX. I know ONNX has been using this form of tracing prior to 1.0 release, but is there any guidance on using ONNX alongside TorchScript annotation?

Can an a traced scriptmodule and already serialised be imported directly using ONNX as is, or do we follow the same ONNX export process, which would seem to retrace the modules?

3 Likes

Bumping because I have the same question. :thinking:

If you want to export to ONNX, nothing on that workflow changes. Tracing / Scripting has slightly different semantics from ONNX export, because ONNX needs statically known shapes of all inputs / intermediates, while TorchScript / jit.trace erase that information in the stored graph.