-
Notifications
You must be signed in to change notification settings - Fork 13
Fix initializer handling in LiftSubgraphInitializersToMainGraphPass pass #148
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
Conversation
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #148 +/- ##
==========================================
- Coverage 76.41% 76.28% -0.13%
==========================================
Files 40 40
Lines 4723 4731 +8
Branches 932 936 +4
==========================================
Hits 3609 3609
- Misses 824 828 +4
- Partials 290 294 +4 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the LiftSubgraphInitializersToMainGraphPass
where the pass would incorrectly attempt to lift initializers that are outputs of subgraphs, which is invalid since these values still belong to the subgraph.
- Added a check to prevent lifting initializers that are subgraph outputs
- Fixed the
infer_attribute_type
function to properly handle empty sequences instead of defaulting to INTS - Improved the name deduplication logic for lifted initializers to ensure unique naming
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/onnx_ir/passes/common/constant_manipulation.py |
Added output check and fixed name deduplication logic in the lift pass |
src/onnx_ir/_convenience/__init__.py |
Fixed empty sequence handling in attribute type inference |
src/onnx_ir/passes/common/constant_manipulation_test.py |
Added test case for the new output initializer handling |
Due to changes onnx/ir-py#148, we cannot create an empty list attribute without specifying type because it would be ambiguous. Fix #2496 Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Previously when an initializer in a sub-graph is an output to the subgraph, the pass would attempt to lift the initializer. Since the value still belongs to the subgraph, this is invalid.
(Q: Can an initializer be an output to a graph? For now I assume yes.)
This change inlcludes fixes:
BC Breaking
When an attribute is an empty list, users need to create an ir.Attr explicitly because the type would otherwise be ambiguous. Previously it was defaulted to be INTS, which is not a behavior by design.
Fixes microsoft/onnxscript#2493