Skip to content

Fix optional input positions in converter#2961

Open
the0cp wants to merge 3 commits into
microsoft:mainfrom
the0cp:optional-input-positions
Open

Fix optional input positions in converter#2961
the0cp wants to merge 3 commits into
microsoft:mainfrom
the0cp:optional-input-positions

Conversation

@the0cp

@the0cp the0cp commented Jul 12, 2026

Copy link
Copy Markdown

Summary

  • Preserve empty input positions when a later optional ONNX input is supplied
  • Allow the converter to consume normalized None placeholders
  • Add generic argument-partitioning tests
  • Add a Resize conversion and ONNX Runtime regression test

Fixes #2007

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a converter/argument-partitioning bug where omitted optional ONNX inputs were dropped, causing later optional inputs (e.g., Resize(..., sizes=...)) to shift into the wrong input positions and produce invalid models for ONNX Runtime.

Changes:

  • Preserve “holes” for omitted optional inputs when a later input is provided (positional or keyword) during argument partitioning.
  • Update the converter to accept normalized None placeholders (in addition to parsed ast.Constant(None)) for optional inputs.
  • Add targeted unit tests and an ONNX Runtime regression test for Resize(..., sizes=...) ensuring required empty inputs are preserved.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
onnxscript/_internal/param_manipulation.py Tracks omitted optional inputs and inserts None placeholders only when needed to preserve later input positions.
onnxscript/_internal/param_manipulation_test.py Adds parameterized tests covering preserved optional input positions (including explicit None).
onnxscript/_internal/converter.py Allows _translate_opt_expr to handle None placeholders introduced by normalization.
onnxscript/_internal/converter_test.py Adds an ONNX Runtime regression test validating Resize inputs include the required empty slots.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.66%. Comparing base (00de62e) to head (c6a0c8f).

Files with missing lines Patch % Lines
onnxscript/_internal/converter_test.py 88.88% 1 Missing ⚠️
onnxscript/_internal/param_manipulation.py 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2961      +/-   ##
==========================================
+ Coverage   72.64%   72.66%   +0.01%     
==========================================
  Files         265      265              
  Lines       32192    32221      +29     
  Branches     3038     3041       +3     
==========================================
+ Hits        23385    23412      +27     
- Misses       7776     7777       +1     
- Partials     1031     1032       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI review requested due to automatic review settings July 24, 2026 07:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Translation of inputs to Resize, when using 'sizes' argument, drops required inputs

2 participants