Preserve output names for returned input aliases - #3018
Open
TANGBUDU wants to merge 2 commits into
Open
Conversation
Author
|
Justin Chu (@justinchuby) gentle ping on this PR when you have a chance. It addresses #2714 and is ready for review. Happy to address any feedback — thanks! |
Check the resolved ONNX value rather than looking its name up in the mutable Python symbol table. Cover input rebinding and collisions with existing input names, including duplicate returns and numerical parity. Assisted-by: ChatGPT
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.
Fixes #2714.
When a graph input is returned through a local alias, use the alias name for the inserted
Identityoutput instead of the genericreturn_valname. Directly returning an unchanged graph input keeps the existing naming behavior. Generated names still go through the existing uniqueness allocator.The method audit found a missed case:
Y = X; X = op.Neg(X); return Yreturned the original input under the nameX, notY. Looking up the resolved ONNX name in the mutable Python symbol table incorrectly classified the value afterXwas rebound. The converter now checks the resolved IR value directly.Regression coverage includes input-name rebinding, collisions with an existing input name, duplicate alias returns, ONNX checker validation, and runtime output parity. The rebinding regression fails before the follow-up fix (
'X' != 'Y') and passes afterward.Tests (2026-09-07):
python -m pytest onnxscript/_internal/converter_test.py -q: 56 passed, 1 skipped, 1 xfailed, 3 xpassed; 160 subtests passed, both with ONNX 1.22.0 / ONNX Runtime 1.29.0 and with ONNX 1.18.0 / ONNX Runtime 1.23.0 / ONNX IR 0.1.16.lintrunner -a: no lint issues.git diff --check: clean.AI assistance was used for the source audit, patch preparation, and validation. The existing expected-failure / unexpected-pass results are reported above, not counted as ordinary passes.