-
Notifications
You must be signed in to change notification settings - Fork 98
Create helper for comparing semantic equivalence of shapes #2620
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 <[email protected]>
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 pull request introduces semantic shape and dimension comparison utilities to improve correctness when handling symbolic or unknown values in the intermediate representation. The changes replace direct equality checks with more robust comparison functions that properly handle edge cases.
Key changes:
- Added
same_shapeandsame_dimutility functions to_ir_utils.pyfor robust shape/dimension comparison - Refactored existing rewrite rules to use the new utilities instead of direct equality checks
- Standardized imports to use
_ir_utilsconsistently across affected files
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
onnxscript/rewriter/_ir_utils.py |
Added new same_shape and same_dim utility functions for semantic comparison |
onnxscript/rewriter/rules/common/_redundant_scatter_nd.py |
Updated to use new utilities and standardized import format |
onnxscript/rewriter/rules/common/_collapse_slices.py |
Refactored shape comparison logic to use new utilities |
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
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
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2620 +/- ##
==========================================
- Coverage 70.32% 70.31% -0.01%
==========================================
Files 222 222
Lines 26224 26237 +13
Branches 2624 2628 +4
==========================================
+ Hits 18442 18449 +7
- Misses 6865 6868 +3
- Partials 917 920 +3 ☔ View full report in Codecov by Sentry. |
This pull request introduces new utility functions for comparing shapes and dimensions in the intermediate representation (IR) utilities, and refactors existing rewrite rules to use these new utilities. The goal is to improve semantic correctness and code clarity when checking shape and dimension equality, especially in the presence of symbolic or unknown values.
Key changes:
New IR utility functions:
same_shapeandsame_dimfunctions to_ir_utils.pyfor more robust and semantically correct comparison of shapes and dimensions, accounting for unknown or symbolic values.Refactoring of rewrite rules to use new utilities:
_collapse_slices.pyand_redundant_scatter_nd.pyto use_ir_utils.same_shapeand_ir_utils.same_diminstead of direct equality checks or previous logic, ensuring that shape and dimension comparisons are handled consistently and correctly. [1] [2] [3]Code consistency improvements:
_ir_utilsconsistently, replacing previous aliasing or direct imports. [1] [2] [3]