Skip to content

Commit 8eadd4e

Browse files
committed
refactor
1 parent d885351 commit 8eadd4e

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

tf2onnx/convert.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
import tensorflow as tf
1616

17-
from tf2onnx import optimizer
1817
from tf2onnx.tfonnx import process_tf_graph, tf_optimize
19-
from tf2onnx import constants, loader, logging, utils
18+
from tf2onnx import constants, loader, logging, utils, optimizer
2019

2120

2221
# pylint: disable=unused-argument
@@ -146,8 +145,6 @@ def main():
146145
inputs_as_nchw=args.inputs_as_nchw)
147146

148147
onnx_graph = optimizer.optimize_graph(g)
149-
if not onnx_graph:
150-
onnx_graph = g
151148
model_proto = onnx_graph.make_model("converted from {}".format(model_path))
152149

153150
# write onnx graph

tf2onnx/optimizer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def optimize_graph(graph):
4747
logger.verbose("Apply %s", name)
4848
current = copy.deepcopy(graph)
4949
opt = factory()
50-
graph = opt.optimize(current)
50+
graph = opt.optimize(current) or graph
5151
continue_flag = continue_flag or opt.graph_been_opt
5252

5353
except Exception: # pylint: disable=broad-except

0 commit comments

Comments
 (0)