def generate_sub_graph(self, graph: Graph, match: SubgraphMatch):
     replacement_desc = match.custom_replacement_desc
     op = Op.get_op_class_by_name(replacement_desc.op)(
         graph, match.custom_replacement_desc.custom_attributes)
     op.default_backend_attrs = list(
         match.custom_replacement_desc.custom_attributes.keys())
     if 'infer' not in op.attrs:
         # update IE attrs
         op.substitute_ie_attrs(op.attrs)
         node = merge_nodes(graph, match.matched_nodes_names(),
                            replacement_desc.get_inputs_description(),
                            replacement_desc.get_outputs_description())
         node.name = graph.unique_id(op.attrs['type'])
         node_attrs = graph.node[node.id]
         # copy attributes which are defined in the custom operation
         for key in op.attrs.keys():
             if key not in ['name', 'op']:
                 node_attrs[key] = op.attrs[key]
         # functions below should return nothing because 'merge_nodes' already created input/output edges
         self.input_edges_match = lambda gr, ma, new_sub_graph: dict()  # pylint: disable=method-hidden
         self.output_edges_match = lambda gr, ma, new_sub_graph: dict()  # pylint: disable=method-hidden
     else:
         node = op.add_node(name=op.attrs['type'] + '_')
         node.type = op.attrs['type']
     return {'new_node': node}
 def nodes_to_remove(self, graph: Graph, match: SubgraphMatch):
     return match.matched_nodes_names()
示例#3
0
 def nodes_to_remove(self, graph: Graph, match: SubgraphMatch):
     new_nodes_to_remove = match.matched_nodes_names()
     new_nodes_to_remove.remove(match.single_input_node(0)[0].id)
     new_nodes_to_remove.remove(match.single_input_node(1)[0].id)
     new_nodes_to_remove.remove(match.single_input_node(2)[0].id)
     return new_nodes_to_remove