From d9d0228d0bb60db9f36dc7b3561667a22264ade7 Mon Sep 17 00:00:00 2001 From: KeDengMS Date: Thu, 12 Aug 2021 17:57:28 -0700 Subject: [PATCH] [Symbolic shape infer] fix a bug in loop/scan (#8694) In Loop/Scan, subgraph output may be partly in subgraph input --- onnxruntime/python/tools/symbolic_shape_infer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime/python/tools/symbolic_shape_infer.py b/onnxruntime/python/tools/symbolic_shape_infer.py index fbf2aaef68..0bc5523779 100755 --- a/onnxruntime/python/tools/symbolic_shape_infer.py +++ b/onnxruntime/python/tools/symbolic_shape_infer.py @@ -1711,8 +1711,8 @@ class SymbolicShapeInference: # topological sort nodes, note there might be dead nodes so we check if all graph outputs are reached to terminate sorted_nodes = [] sorted_known_vi = set([i.name for i in list(self.out_mp_.graph.input) + list(self.out_mp_.graph.initializer)]) - if all([o.name in sorted_known_vi for o in self.out_mp_.graph.output]): - # Loop/Scan will have all graph output in graph inputs, so don't do topological sort + if any([o.name in sorted_known_vi for o in self.out_mp_.graph.output]): + # Loop/Scan will have some graph output in graph inputs, so don't do topological sort sorted_nodes = self.out_mp_.graph.node else: while not all([o.name in sorted_known_vi for o in self.out_mp_.graph.output]):