From c4a52820a53b493a815cc9002453fb2d7ee1ff31 Mon Sep 17 00:00:00 2001 From: donglinb <65906596+donglinb@users.noreply.github.com> Date: Sat, 15 Oct 2022 05:06:31 +0800 Subject: [PATCH] bug fix for symbolic shape infer (#13067) --- onnxruntime/python/tools/symbolic_shape_infer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/onnxruntime/python/tools/symbolic_shape_infer.py b/onnxruntime/python/tools/symbolic_shape_infer.py index e5157f90ee..2af4b8a4fe 100755 --- a/onnxruntime/python/tools/symbolic_shape_infer.py +++ b/onnxruntime/python/tools/symbolic_shape_infer.py @@ -41,6 +41,13 @@ def get_shape_from_type_proto(type_proto): return None # note no shape is different from shape without dim (scalar) +def get_elem_type_from_type_proto(type_proto): + if is_sequence(type_proto): + return type_proto.sequence_type.elem_type.tensor_type.elem_type + else: + return type_proto.tensor_type.elem_type + + def get_shape_from_value_info(vi): cls_type = vi.type.WhichOneof("value") if cls_type is None: @@ -570,7 +577,7 @@ class SymbolicShapeInference: vi.CopyFrom( helper.make_tensor_value_info( node.output[0], - self.known_vi_[node.input[0]].type.tensor_type.elem_type, + get_elem_type_from_type_proto(self.known_vi_[node.input[0]].type), self._get_shape(node, 0), ) )