Skip to content

Commit c2620f7

Browse files
committed
Reshape does not support INT32
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent 0bcd3bc commit c2620f7

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

onnxscript/optimizer/_constant_folding.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,6 @@ def set_sym_value(self, value: ir.Value, sym_value: SymbolicValue) -> None:
196196

197197
def get_shape_value(self, value: ir.Value | None) -> ir.Shape | None:
198198
const_value = _get_numpy_value(value, ir.DataType.INT64, size_limit=10)
199-
if const_value is None:
200-
# Reshape accepts shape input of INT32 type as well, so we also check for INT32 here
201-
# This is common for tflite models
202-
const_value = _get_numpy_value(value, ir.DataType.INT32, size_limit=10)
203199
if const_value is not None:
204200
if const_value.ndim == 1:
205201
return ir.Shape(const_value.tolist())

onnxscript/optimizer/_constant_folding_test.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -614,22 +614,6 @@ def test_gather_symdim(self):
614614
optimized = self._fold(model)
615615
self.assertEqual(optimized.graph.node(-1).op_type, "Identity")
616616

617-
def test_reshape_identity_int32_shape(self):
618-
"""Reshape with a constant INT32 shape input should be recognized as identity."""
619-
model_ir = ir.from_onnx_text(
620-
"""
621-
<ir_version: 7, opset_import: [ "" : 17]>
622-
agraph (float[3, 4] x) => (float[3, 4] z)
623-
{
624-
shape_i64 = Constant <value_ints=[3, 4]> ()
625-
shape = Cast <to=6> (shape_i64)
626-
z = Reshape (x, shape)
627-
}
628-
"""
629-
)
630-
optimized = self._fold(model_ir)
631-
self.assertEqual(optimized.graph.node(-1).op_type, "Identity")
632-
633617
def test_input_size_limit(self):
634618
model_text = """
635619
<ir_version: 7, opset_import: [ "" : 17]>

0 commit comments

Comments
 (0)