Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ MO ] Fix for remove_op_node_with_data_node #1934

Merged
merged 2 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion model-optimizer/extensions/middle/UselessMerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ def pattern(self):

def replace_pattern(self, graph: Graph, match: dict):
if len(graph.in_edges(match['merge'].id)) <= 1:
remove_op_node_with_data_node(graph, match['merge'])
remove_op_node_with_data_node(graph, match['merge'], list(match['merge'].in_nodes().values())[0])
log.info("Useles Merge op and data nodes was deleted op='{}'".format(match['merge'].id))
5 changes: 3 additions & 2 deletions model-optimizer/mo/middle/passes/eliminate.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ def merge_data_nodes(graph, survived, removed):


# TODO: unit tests
def remove_op_node_with_data_node(graph, node_to_remove):
def remove_op_node_with_data_node(graph, node_to_remove, input_data_node=None):
from mo.graph.graph import Node
assert node_to_remove.kind == 'op'
input_data_node = node_to_remove.in_node()
if input_data_node is None:
input_data_node = node_to_remove.in_node()
output_node = [v for _, v in graph.out_edges(node_to_remove.id)]
assert len(output_node) == 1, "Cannot remove node producing two or more output tensors"
output_node = Node(graph, output_node[0])
Expand Down