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 · 2 comments
Open

Treatment of optional inputs to nodes when empty #22035

shubhambhokare1 opened this issue Sep 9, 2024 · 2 comments
Labels
core runtime issues related to core runtime stale issues that have not been addressed in a while; categorized by a bot

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.

skottmckay added a commit that referenced this issue Sep 20, 2024
### Description
<!-- Describe your changes. -->
The optional `axes` input may exist with an empty name and be a nullptr.

Update the CUDA implementation to handle this.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

#22035
Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Oct 17, 2024
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 stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

3 participants