提交 97f2accc 编写于 作者: J jiangjiajun

add tools for PaddleLite op check

上级 d4531ad4
import urllib
import sys
from paddle.fluid.framework import Program
ops_h = "https://raw.githubusercontent.com/PaddlePaddle/Paddle-Lite/develop/lite/api/_paddle_use_ops.h"
try:
fetch = urllib.urlretrieve(ops_h, "./_paddle_use_ops.h")
except:
fetch = urllib.request.urlretrieve(ops_h, "./_paddle_use_ops.h")
ops = list()
with open("./_paddle_use_ops.h") as f:
for line in f:
if "USE_LITE_OP" in line:
op = line.strip().split('(')[1].split(')')[0]
ops.append(op)
model_file = sys.argv[1]
with open(model_file, 'rb') as f:
program = Program.parse_from_string(f.read())
unsupported_ops = set()
for op in program.blocks[0].ops:
if op.type not in ops:
unsupported_ops.add(op.type)
nums = len(unsupported_ops)
if len(unsupported_ops) > 0:
print("========= {} OPs are not supported in Paddle-Lite=========".format(
nums))
for op in unsupported_ops:
print("========= {} ========".format(op))
else:
print("\n========== Good News! ========")
print("Good! All ops in this model are supported in Paddle-Lite!\n")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册