-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PFTO] Support ONNX export with list inputs #572
Comments
We can add custom handler of pytorch-pfn-extras/pytorch_pfn_extras/onnx/pfto_exporter/export.py Lines 458 to 463 in a27e3d4
|
PFTO seems to enable |
This is done in This API is assumed to be internal and they recommend to use |
It seems |
To support list inputs and models with list operators in
ppe.onnx.export_testcase
, we have two topics.How to handle list inputs
Roughly, we have two choices
ppe.onnx.export
always exports a onnx and testcase whose inputs are allTensor
s.I think we should go with the first way because
torch.onnx.export
does so.Thus, torch.onnx.export actually accepts calls like
torch.onnx.export(model, (list_arg,), input_names=["a", "b", "c"], ...)
.This is because torch.onnx.export calls
torch.jit._get_trace_graph
and list inputs are automatically unrolled in it. However, this API is internal and with publictorch.jit.trace
, list inputs are kept as list. (For more detail, see #572 (comment)).Since PFTO uses
torch.jit.trace
, one viable way is to create a wrapper model that accepts unrolled inputs.Add support for more list operators
We have to implement custom symbolic execution for
prim::ListUnpack
,prim::TupleConstruct
, etc... (prim::ListConstruct
, which is the most used one, is already implemented).I haven't fully understood the symbolic execution of
prim::ListConstruct
-like nodes intorch.onnx.export
.For future survey, I leave some memo:
torch.onnx.export
doesonnx_peephole
optimization which includeseraseListConstruct
oreraseListUnpack
, after_C._jit_pass_onnx(graph, operator_export_type)
. In my understanding,prim::ListConstruct
and similar ops are replaced with onnx operators by symbolic execution. Why they remain after_C.jit_pass_onnx
?It seems to me that the handling of
prim::ListConstruct
-like ops has not been stable. Maybe we should wait a little bit to stabilize our implementation.The text was updated successfully, but these errors were encountered: