Skip to content

Commit 2b477f9

Browse files
committed
refactor
1 parent 1e342bd commit 2b477f9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

tf2onnx/optimizer/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def optimize_graph(graph):
4848
current = copy.deepcopy(graph)
4949
opt = factory()
5050
graph = opt.optimize(current)
51-
if not continue_flag:
52-
continue_flag = opt.graph_been_opt
51+
continue_flag = continue_flag or opt.graph_been_opt
5352

5453
except Exception: # pylint: disable=broad-except
5554
# if current optimizer fails, continue with other optimizers

tf2onnx/optimizer/optimizer_base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class GraphOptimizerBase(object):
1616

1717
def __init__(self):
1818
self._logger = logging.getLogger('.'.join(__name__.split('.')[:-1] + [self.__class__.__name__]))
19-
self.graph_been_opt = False
19+
self._graph_been_opt = False
2020

2121
@property
2222
def logger(self):
@@ -26,6 +26,14 @@ def logger(self):
2626
def is_debug_mode(self):
2727
return utils.is_debug_mode()
2828

29+
@property
30+
def graph_been_opt(self):
31+
return self._graph_been_opt
32+
33+
@graph_been_opt.setter
34+
def graph_been_opt(self, value):
35+
self._graph_been_opt = value
36+
2937
def optimize(self, graph):
3038
""" Optimize graph, return optimized graph. """
3139
before = graph.dump_node_statistics()

0 commit comments

Comments
 (0)