You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create helper for comparing semantic equivalence of shapes (#2620)
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:**
* Added `same_shape` and `same_dim` functions to `_ir_utils.py` for more
robust and semantically correct comparison of shapes and dimensions,
accounting for unknown or symbolic values.
**Refactoring of rewrite rules to use new utilities:**
* Updated `_collapse_slices.py` and `_redundant_scatter_nd.py` to use
`_ir_utils.same_shape` and `_ir_utils.same_dim` instead of direct
equality checks or previous logic, ensuring that shape and dimension
comparisons are handled consistently and correctly.
[[1]](diffhunk://#diff-bd2dba53e1a4b4fb79975f7bceacf4b1c5b0b38a10d953af1e18a0b7af6c1050L85-R88)
[[2]](diffhunk://#diff-47bc4cbfc2fee996791be5a58bf9447dd44dd833e540139b5cd18b807757be4aL57-R57)
[[3]](diffhunk://#diff-47bc4cbfc2fee996791be5a58bf9447dd44dd833e540139b5cd18b807757be4aL90-R90)
**Code consistency improvements:**
* Standardized imports in affected files to use `_ir_utils`
consistently, replacing previous aliasing or direct imports.
[[1]](diffhunk://#diff-bd2dba53e1a4b4fb79975f7bceacf4b1c5b0b38a10d953af1e18a0b7af6c1050L8-R8)
[[2]](diffhunk://#diff-47bc4cbfc2fee996791be5a58bf9447dd44dd833e540139b5cd18b807757be4aL23-R23)
[[3]](diffhunk://#diff-47bc4cbfc2fee996791be5a58bf9447dd44dd833e540139b5cd18b807757be4aL44-R44)
---------
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
0 commit comments