Speed up determined_sort which speeds up emitting the IR (#4928)

This commit is contained in:
Maxim Vafin 2021-03-26 12:50:57 +03:00 committed by GitHub
parent da7c2dfc2b
commit 851e203f72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,12 +40,11 @@ def determined_sort(outputs: list):
stack = list(outputs)
visited = set()
while len(stack) != 0:
node = stack[0]
node = stack.pop(0)
node_id = node.id
stack.pop(0)
visited.add(node_id)
has_child = False
in_names = [n.id if isinstance(node.in_nodes(), list) else node.in_node(n).id for n in node.in_nodes()]
in_names = [n for n, d in node.get_inputs()]
for in_node_name in in_names:
if in_node_name not in visited:
stack.insert(0, node)