提交 3f5c56c7 编写于 作者: W wjj19950828

update optimize log

上级 65551bd6
...@@ -42,17 +42,22 @@ class GraphOptimizer(object): ...@@ -42,17 +42,22 @@ class GraphOptimizer(object):
self.passes = [] self.passes = []
def optimize(self, graph): def optimize(self, graph):
show_pass_log = False
for pass_name in self.passes: for pass_name in self.passes:
pass_ = PassManager.lookup(pass_name)() pass_ = PassManager.lookup(pass_name)()
if pass_name.endswith("_eliminate_pass") or pass_name.endswith( if pass_name.endswith("_eliminate_pass") or pass_name.endswith(
"conv2d_add_fuse_pass"): "conv2d_add_fuse_pass"):
pass_.apply(graph) pass_.apply(graph)
show_pass_log = True
else: else:
while True: while True:
before_len = len(graph.layers) before_len = len(graph.layers)
pass_.apply(graph) pass_.apply(graph)
after_len = len(graph.layers) after_len = len(graph.layers)
if after_len < before_len:
show_pass_log = True
if before_len == after_len: if before_len == after_len:
break break
print("{} done!".format(pass_name)) if show_pass_log:
print("{} done!".format(pass_name))
return graph return graph
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册