torchrec icon indicating copy to clipboard operation
torchrec copied to clipboard

[feature request] support exporting the model to ONNX format

Open opringle opened this issue 2 years ago • 2 comments

Currently attempting to export a model that uses KeyedJaggedTensor to ONNX format results in the following error:

gm = symbolic_trace(model)
scripted_gm: torch.jit.ScriptModule | torch.jit.ScriptFunction = torch.jit.script(gm)  # type: ignore

torch.onnx.export(
    model=scripted_gm,
    args=...,
    f="model.onnx",
    export_params=True,
    verbose=True,
    opset_version=10,
    do_constant_folding=True,
    input_names=["input"],
    output_names=["output"],
    dynamic_axes={
        "input": {0: "batch_size"},
        "output": {0: "batch_size"},
    },
)
RuntimeError: Only tuples, lists and Variables are supported as JIT inputs/outputs. Dictionaries and strings are also accepted, but their usage is not recommended. Here, received an input of unsupported type: KeyedJaggedTensor

opringle avatar Dec 03 '23 16:12 opringle

Linking related issue: https://github.com/pytorch/torchrec/issues/1221

henrylhtsang avatar Dec 07 '23 19:12 henrylhtsang

Is this a feature request we should make to the onnx team or torchrec team?

opringle avatar Dec 07 '23 23:12 opringle