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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treatment of optional inputs to nodes when empty #22035

Open
shubhambhokare1 opened this issue Sep 9, 2024 · 1 comment
Open

Treatment of optional inputs to nodes when empty #22035

shubhambhokare1 opened this issue Sep 9, 2024 · 1 comment
Labels
core runtime issues related to core runtime

Comments

@shubhambhokare1
Copy link
Contributor

shubhambhokare1 commented Sep 9, 2024

Describe the issue

In the pytorch-onnx exporter, when an optional input is not provided, it is defaulted to None, which gets translates to "" in the onnx graph. Semantically, "" and nothing should be the same in the ONNX spec, however this runs into issues for ops such as reduction ops and squeeze.

To reproduce

if (num_inputs == 2) {
// override the attribute value with the input value for reduction_axes
const Tensor* axes_tensor = ctx->Input<Tensor>(1);
ORT_ENFORCE(axes_tensor != nullptr, "Axes input is null");
ORT_ENFORCE(axes_tensor->Shape().NumDimensions() == 1, "An axes tensor must be a vector tensor.");

In this example for Reduction ops, let's say we have axes=None, this is now exported as axes="". So ORT still counts this as two inputs and the example fails as axes is Null. Ideally, this empty input, should not count as one of the inputs to the node.

Urgency

No response

Platform

Linux

OS Version

Mariner 2.0

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.18.0

ONNX Runtime API

Python

Architecture

X64

Execution Provider

Default CPU, CUDA

Execution Provider Library Version

CUDA 12.4

@yuslepukhin yuslepukhin added the core runtime issues related to core runtime label Sep 10, 2024
@skottmckay
Copy link
Contributor

Yeah - that's a bug. It should be checking to handle the 'input with empty name' case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core runtime issues related to core runtime
Projects
None yet
Development

No branches or pull requests

3 participants