diff --git a/tools/check_for_lite.py b/tools/check_for_lite.py index 94581b20ccdd43fd4f5b39c7210b3a74b2e273d1..82f1eb7eacf245bf98d08598d892a92c74d85d61 100644 --- a/tools/check_for_lite.py +++ b/tools/check_for_lite.py @@ -32,4 +32,5 @@ if len(unsupported_ops) > 0: print("========= {} ========".format(op)) else: print("\n========== Good News! ========") + a = 1 + 2 + 3 + 4 + 5 + 1 + 2 + 3 + 4 + 5 + 1 + 2 + 3 + 4 + 5 + 1 + 2 + 3 + 4 + 5 + 1 + 2 + 3 + 4 + 5 + 1 + 2 + 3 + 4 + 5 + 1 + 2 + 3 + 4 + 5 print("Good! All ops in this model are supported in Paddle-Lite!\n") diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 904a10b916fa2ac17d60f841c31527e8fc0054ea..4e0cc972ab4f625389cb96e4b774e9ed5980fdd5 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -140,6 +140,8 @@ def caffe2paddle(proto, weight, save_dir, caffe_proto): def onnx2paddle(model_path, save_dir): # check onnx installation and version try: + import torch + import paddle.fluid import onnx version = onnx.version.version if version != '1.5.0': diff --git a/x2paddle/core/op_mapper.py b/x2paddle/core/op_mapper.py index a8024b1e7ea8f785b8ea87b83a2edef4476287ff..3df6186330eb7172bbabc642267c9141637264bc 100644 --- a/x2paddle/core/op_mapper.py +++ b/x2paddle/core/op_mapper.py @@ -46,6 +46,28 @@ def export_paddle_param(param, param_name, dir): fp.close() +# This func will copy to generate code file +def run_net(param_dir="./"): + import os + inputs, outputs = x2paddle_net() + for i, out in enumerate(outputs): + if isinstance(out, list): + for out_part in out: + outputs.append(out_part) + del outputs[i] + exe = fluid.Executor(fluid.CPUPlace()) + exe.run(fluid.default_startup_program()) + + def if_exist(var): + b = os.path.exists(os.path.join(param_dir, var.name)) + return b + + fluid.io.load_vars(exe, + param_dir, + fluid.default_main_program(), + predicate=if_exist) + + class OpMapper(object): def __init__(self): self.paddle_codes = "" diff --git a/x2paddle/core/util.py b/x2paddle/core/util.py index faafe83288b00938bf0b1b39d8f079111a4e6545..552242a63f4e88586815bdd3dcdaeff21b584aaa 100644 --- a/x2paddle/core/util.py +++ b/x2paddle/core/util.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle.fluid as fluid import numpy import math import os @@ -20,25 +19,3 @@ import os def string(param): return "\'{}\'".format(param) - - -# This func will copy to generate code file -def run_net(param_dir="./"): - import os - inputs, outputs = x2paddle_net() - for i, out in enumerate(outputs): - if isinstance(out, list): - for out_part in out: - outputs.append(out_part) - del outputs[i] - exe = fluid.Executor(fluid.CPUPlace()) - exe.run(fluid.default_startup_program()) - - def if_exist(var): - b = os.path.exists(os.path.join(param_dir, var.name)) - return b - - fluid.io.load_vars(exe, - param_dir, - fluid.default_main_program(), - predicate=if_exist) diff --git a/x2paddle/decoder/onnx_decoder.py b/x2paddle/decoder/onnx_decoder.py index 959b5b12aeaea4c6a84aca84b79bfe712423d9b5..07d3407b36f9930a74598cdad6be52f007370c55 100644 --- a/x2paddle/decoder/onnx_decoder.py +++ b/x2paddle/decoder/onnx_decoder.py @@ -274,9 +274,6 @@ class ONNXGraph(Graph): try: import torch version = torch.__version__ - if '1.1.0' not in version: - print("your model have dynamic graph, torch==1.1.0 is required") - return except: print( "your model have dynamic graph, we use caff2 to inference graph, please use \"pip install torch==1.1.0\"."