Skip to content

Commit 62de1f0

Browse files
committed
Fix collapse slices rewrite rules to handle unknown dims
Signed-off-by: Justin Chu <[email protected]>
1 parent dddf0c2 commit 62de1f0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"packaging",
4343
"protobuf",
4444
)
45-
ONNX_IR = "onnx_ir==0.1.9"
45+
ONNX_IR = "onnx_ir==0.1.10"
4646
ONNX_IR_MAIN = "git+https://github.com/onnx/ir-py.git@main#egg=onnx_ir"
4747

4848

onnxscript/rewriter/rules/common/_collapse_slices.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def _same_shape(op, data: ir.Value, slice_output: ir.Value, steps: ir.Value, **_
8585
if not is_singleton_value(steps, 1):
8686
return False
8787

88+
# If any dim is unknown, the shapes are not the same
89+
if data.shape.has_unknown_dim() or slice_output.shape.has_unknown_dim():
90+
return False
91+
8892
return data.shape == slice_output.shape
8993

9094

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ classifiers = [
2727
dependencies = [
2828
"ml_dtypes",
2929
"numpy",
30-
"onnx_ir>=0.1.9,<2", # Expect onnx_ir to have a breaking change in 2.0. If not, extend this range.
30+
"onnx_ir>=0.1.10,<2", # Expect onnx_ir to have a breaking change in 2.0. If not, extend this range.
3131
"onnx>=1.16",
3232
"packaging",
3333
"typing_extensions>=4.10",

0 commit comments

Comments
 (0)