提交 cc865fd6 编写于 作者: J jiangjiajun

test

上级 78e76da7
...@@ -32,4 +32,5 @@ if len(unsupported_ops) > 0: ...@@ -32,4 +32,5 @@ if len(unsupported_ops) > 0:
print("========= {} ========".format(op)) print("========= {} ========".format(op))
else: else:
print("\n========== Good News! ========") 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") print("Good! All ops in this model are supported in Paddle-Lite!\n")
...@@ -140,6 +140,8 @@ def caffe2paddle(proto, weight, save_dir, caffe_proto): ...@@ -140,6 +140,8 @@ def caffe2paddle(proto, weight, save_dir, caffe_proto):
def onnx2paddle(model_path, save_dir): def onnx2paddle(model_path, save_dir):
# check onnx installation and version # check onnx installation and version
try: try:
import torch
import paddle.fluid
import onnx import onnx
version = onnx.version.version version = onnx.version.version
if version != '1.5.0': if version != '1.5.0':
......
...@@ -46,6 +46,28 @@ def export_paddle_param(param, param_name, dir): ...@@ -46,6 +46,28 @@ def export_paddle_param(param, param_name, dir):
fp.close() 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): class OpMapper(object):
def __init__(self): def __init__(self):
self.paddle_codes = "" self.paddle_codes = ""
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.fluid as fluid
import numpy import numpy
import math import math
import os import os
...@@ -20,25 +19,3 @@ import os ...@@ -20,25 +19,3 @@ import os
def string(param): def string(param):
return "\'{}\'".format(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)
...@@ -274,9 +274,6 @@ class ONNXGraph(Graph): ...@@ -274,9 +274,6 @@ class ONNXGraph(Graph):
try: try:
import torch import torch
version = torch.__version__ version = torch.__version__
if '1.1.0' not in version:
print("your model have dynamic graph, torch==1.1.0 is required")
return
except: except:
print( print(
"your model have dynamic graph, we use caff2 to inference graph, please use \"pip install torch==1.1.0\"." "your model have dynamic graph, we use caff2 to inference graph, please use \"pip install torch==1.1.0\"."
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册