提交 6f43b6b6 authored 作者: Ziye Fan's avatar Ziye Fan

remove node.outputs[0] only if all its clients be replaced

上级 82725e73
...@@ -1377,6 +1377,7 @@ def local_fill_sink(node): ...@@ -1377,6 +1377,7 @@ def local_fill_sink(node):
# The newly created node c doesn't has 'clients', # The newly created node c doesn't has 'clients',
# so this iteration is took place with node.outputs[0] # so this iteration is took place with node.outputs[0]
replacements = {node.outputs[0]: c} replacements = {node.outputs[0]: c}
all_clients_replaced = True
for client, cl_idx in node.outputs[0].clients: for client, cl_idx in node.outputs[0].clients:
if (hasattr(client, 'op') and if (hasattr(client, 'op') and
isinstance(client.op, T.Elemwise) and isinstance(client.op, T.Elemwise) and
...@@ -1388,10 +1389,14 @@ def local_fill_sink(node): ...@@ -1388,10 +1389,14 @@ def local_fill_sink(node):
# Add clients to new_client # Add clients to new_client
new_client.owner.outputs[0].clients = client.outputs[0].clients new_client.owner.outputs[0].clients = client.outputs[0].clients
r = local_fill_sink.transform(new_client.owner) r = local_fill_sink.transform(new_client.owner)
if r is False: if not r:
all_clients_replaced = False
continue continue
# replacements.pop(node.outputs[0], None)
replacements.update(r) replacements.update(r)
else:
all_clients_replaced = False
if all_clients_replaced:
replacements.pop(node.outputs[0], None)
return replacements return replacements
register_canonicalize(local_fill_sink) register_canonicalize(local_fill_sink)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论