提交 cd805fa9 编写于 作者: R root

check for onnx model

上级 8058b628
...@@ -163,13 +163,12 @@ def onnx2paddle(model_path, save_dir, params_merge=False): ...@@ -163,13 +163,12 @@ def onnx2paddle(model_path, save_dir, params_merge=False):
return return
print("Now translating model from onnx to paddle.") print("Now translating model from onnx to paddle.")
from x2paddle.op_mapper.onnx_op_mapper import ONNXOpMapper
from x2paddle.decoder.onnx_decoder import ONNXDecoder from x2paddle.decoder.onnx_decoder import ONNXDecoder
model = ONNXDecoder(model_path) from x2paddle.optimizer.onnx_optimizer import ONNXOptimizer
from x2paddle.op_mapper.onnx_op_mapper import ONNXOpMapper model = ONNXDecoder(model_path)
mapper = ONNXOpMapper(model, save_dir) mapper = ONNXOpMapper(model, save_dir)
from x2paddle.optimizer.onnx_optimizer import ONNXOptimizer
optimizer = ONNXOptimizer(mapper) optimizer = ONNXOptimizer(mapper)
optimizer.delete_redundance_code() optimizer.delete_redundance_code()
......
...@@ -141,7 +141,12 @@ class ONNXOpMapper(OpMapper): ...@@ -141,7 +141,12 @@ class ONNXOpMapper(OpMapper):
onnx.save(model, os.path.join(self.tmp_data_dir, onnx.save(model, os.path.join(self.tmp_data_dir,
'onnx_model_infer.onnx')) 'onnx_model_infer.onnx'))
os.system('onnx_infer --save_dir=' + self.tmp_data_dir) is_success = os.system('onnx_infer --save_dir=' + self.tmp_data_dir)
if is_success != 0:
raise Exception("onnxruntime inference onnx model failed, Please \
confirm the correctness of onnx model by onnxruntime, \
if onnx model is valid, you can submit issue in github."
)
return return
def get_dynamic_shape(self, layer): def get_dynamic_shape(self, layer):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册