diff --git a/x2paddle/optimizer/tf_optimizer.py b/x2paddle/optimizer/tf_optimizer.py index 2111ee8bb6a58f7ee791448688d9a4a95b3aea86..fcf6cdfbbb8e4b44b163141b719201d06ff9a9ad 100644 --- a/x2paddle/optimizer/tf_optimizer.py +++ b/x2paddle/optimizer/tf_optimizer.py @@ -15,56 +15,8 @@ # TODO useless node remove from x2paddle.decoder.tf_decoder import TFGraph +# TODO bn merge -class TFGraphOptimizer(object): - def __init__(self): - print("Doint Nothing") +# TODO activation merge - def remove_isolated_node(self, graph): - # delete isolated nodes - isolated_nodes = list() - for node_name in graph.node_map.keys(): - if len(graph.get_node(node_name).inputs) == 0 or len( - graph.get_node(node_name).outputs) == 0: - isolated_nodes.append(node_name) - - graph.remove_node(node_name) - - def remove_identity_node(self, graph): - identity_node = list() - for node_name, node in graph.node_map.items(): - if node.layer_type == "Identity": - identity_node.append(node_name) - - for node_name in identity_node: - node = graph.get_node(node_name) - # Remind: Only 1 input for Identity node - input_node = graph.get_node(node.inputs[0]) - - # remove identity node from graph - idx = input_node.outputs.index(node_name) - del input_node.outputs[idx] - - output_names = node.outputs - for output_name in output_names: - output_node = graph.get_node(output_name) - idx = output_node.inputs.index(node_name) - output_node.inputs[idx] = input_node.layer_name - - idx = graph.topo_sort.index(node_name) - del graph.topo_sort[idx] - - def run(self, graph): - self.remove_isolated_node(graph) - self.remove_identity_node(graph) - - -# TODO identity node remove - -# TODO subgraph optimize - -# TODO compute optimize - -# activation merge - -# biasadd merge +# TODO biasadd merge