未验证 提交 7bde440e 编写于 作者: C chenjian 提交者: GitHub

fix export bug when multiple blocks in graph (#1162)

* fix expport bug when multiple blocks in graph

* fix

* refactor code
上级 bce54249
...@@ -26,7 +26,8 @@ def translate_graph(model, input_spec, verbose=True): ...@@ -26,7 +26,8 @@ def translate_graph(model, input_spec, verbose=True):
with tempfile.TemporaryDirectory() as tmp: with tempfile.TemporaryDirectory() as tmp:
model._full_name = '{}[{}]'.format(model.__class__.__name__, "model") model._full_name = '{}[{}]'.format(model.__class__.__name__, "model")
create_opname_scope(model) create_opname_scope(model)
paddle.jit.save(model, os.path.join(tmp, 'temp'), input_spec) model = paddle.jit.to_static(model, input_spec)
paddle.jit.save(model, os.path.join(tmp, 'temp'))
model_data = open(os.path.join(tmp, 'temp.pdmodel'), 'rb').read() model_data = open(os.path.join(tmp, 'temp.pdmodel'), 'rb').read()
result = analyse_model(model_data) result = analyse_model(model_data)
if verbose: if verbose:
......
...@@ -665,7 +665,7 @@ class LogWriter(object): ...@@ -665,7 +665,7 @@ class LogWriter(object):
result = translate_graph(model, input_spec, verbose) result = translate_graph(model, input_spec, verbose)
except Exception as e: except Exception as e:
print("Failed to save model graph, error: {}".format(e)) print("Failed to save model graph, error: {}".format(e))
return raise e
graph_file_name = bfile.join( graph_file_name = bfile.join(
self.logdir, self.logdir,
"vdlgraph.%010d.log%s" % (time.time(), self._filename_suffix)) "vdlgraph.%010d.log%s" % (time.time(), self._filename_suffix))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册