Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Inputs/Outputs with torch.onnx.dynamo_export #127128

Open
khari998 opened this issue May 24, 2024 · 1 comment
Open

Multiple Inputs/Outputs with torch.onnx.dynamo_export #127128

khari998 opened this issue May 24, 2024 · 1 comment
Labels
module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@khari998
Copy link

khari998 commented May 24, 2024

馃悰 Describe the bug

I am getting an error trying to export a model with multiple inputs and outputs.

 dummy_input = torch.randn(
    1, 100, 400
).to(device)
dummy_layer_one_mask = torch.randint(
    0, 2, (1, 10)
).to(device)
dummy_layer_two_mask = torch.randint(
    0, 2, (1,10)
).to(device)

onnx_model = torch.onnx.dynamo_export(
    actor_model,
    (dummy_input, dummy_layer_one_mask, dummy_layer_two_mask),
)

onnx_model.save(f"{model_directory}/model/actor.onnx")

And for the output of the forward method, my model has 4 outputs.
I am returning two maps that have strings as keys and tensors as values for the first two outputs and two tensors for the last two outputs.

I keep getting the error

439, in dynamo_export
    raise OnnxExporterError(
torch.onnx.OnnxExporterError: Failed to export the model to ONNX. Generating SARIF report at 'report_dynamo_export.sarif'. SARIF is a standard format for the output of static analysis tools. SARIF logs can be loaded in VS Code SARIF viewer extension, or SARIF web viewer (https://microsoft.github.io/sarif-web-component/). Please report a bug on PyTorch Github: https://github.com/pytorch/pytorch/issues

and when I tried dragging the sarif file into the website listed, i get a blank page that says no results found.

Are multiple inputs suppored when converting to onnx with dynamo_export? Are dictionaries supported as outputs? From what I understood, ONNX supports maps as outputs. I have a complex architecture so flattening all of these outputs into a single tensor is not ideal at all for me and I would prefer to keep my four outputs in the data structure they currently are in

Versions

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: macOS 14.5 (arm64)
GCC version: Could not collect
Clang version: 15.0.0 (clang-1500.3.9.4)
CMake version: Could not collect
Libc version: N/A

Python version: 3.12.3 (main, Apr 9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] (64-bit runtime)
Python platform: macOS-14.5-arm64-arm-64bit
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Apple M1

Versions of relevant libraries:
[pip3] No relevant packages
[conda] Could not collect

@soulitzer soulitzer added module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels May 28, 2024
@justinchuby
Copy link
Collaborator

Multiple inputs are supported. You would need

onnx_model = torch.onnx.dynamo_export(
    actor_model,
    dummy_input, dummy_layer_one_mask, dummy_layer_two_mask,
)

(unpack the tuple)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants