Fix optional input positions in converter#2961
Open
the0cp wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
Noneplaceholders (in addition to parsedast.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 Report❌ Patch coverage is
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NoneplaceholdersFixes #2007