Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
d85fcc1f
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d85fcc1f
编写于
8月 26, 2019
作者:
S
sangoly
提交者:
Yan Chunwei
8月 26, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[API Generate] fix generate api bug test=develop (#1872)
上级
e936f8c1
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
62 addition
and
38 deletion
+62
-38
lite/tools/cmake_tools/parse_kernel_registry.py
lite/tools/cmake_tools/parse_kernel_registry.py
+47
-27
lite/tools/cmake_tools/parse_op_registry.py
lite/tools/cmake_tools/parse_op_registry.py
+15
-11
未找到文件。
lite/tools/cmake_tools/parse_kernel_registry.py
浏览文件 @
d85fcc1f
...
@@ -24,36 +24,56 @@ out_lines = [
...
@@ -24,36 +24,56 @@ out_lines = [
''
,
''
,
]
]
left_pattern
=
'REGISTER_LITE_KERNEL('
right_pattern
=
')'
def
find_right_pattern
(
context
,
start
):
if
start
>=
len
(
context
):
return
-
1
fake_left_num
=
0
while
start
<
len
(
context
):
if
context
[
start
]
==
right_pattern
:
if
fake_left_num
==
0
:
return
start
else
:
fake_left_num
-=
1
elif
context
[
start
]
==
'('
:
fake_left_num
+=
1
start
+=
1
return
-
1
lines
=
set
()
with
open
(
ops_list_path
)
as
f
:
with
open
(
ops_list_path
)
as
f
:
for
line
in
f
:
for
line
in
f
:
lines
.
add
(
line
.
strip
())
for
line
in
lines
:
path
=
line
.
strip
()
path
=
line
.
strip
()
status
=
''
status
=
''
with
open
(
path
)
as
g
:
with
open
(
path
)
as
g
:
lines
=
[
v
for
v
in
g
]
context
=
''
.
join
([
item
.
strip
()
for
item
in
g
])
for
i
in
range
(
len
(
lines
)):
index
=
0
line
=
lines
[
i
].
strip
()
cxt_len
=
len
(
context
)
while
index
<
cxt_len
and
index
>=
0
:
if
not
status
:
left_index
=
context
.
find
(
left_pattern
,
index
)
key
=
'REGISTER_LITE_KERNEL'
if
left_index
<
0
:
break
if
line
.
startswith
(
key
):
right_index
=
find_right_pattern
(
context
,
left_index
+
len
(
left_pattern
))
forward
=
i
+
min
(
7
,
len
(
lines
)
-
i
)
if
right_index
<
0
:
remaining
=
line
[
len
(
key
)
+
1
:]
+
' '
.
join
(
raise
ValueError
(
"Left Pattern and Right Pattern does not match"
)
[
v
.
strip
()
for
v
in
lines
[
i
+
1
:
forward
]])
tmp
=
context
[
left_index
+
len
(
left_pattern
)
:
right_index
]
index
=
right_index
+
1
x
=
remaining
.
find
(
'.'
)
if
tmp
.
startswith
(
'/'
):
continue
if
x
>
0
:
fields
=
[
item
.
strip
()
for
item
in
tmp
.
split
(
','
)]
remaining
=
remaining
[:
x
]
if
len
(
fields
)
<
6
:
raise
ValueError
(
"Invalid REGISTER_LITE_KERNEL format"
)
fs
=
[
v
.
strip
()
for
v
in
remaining
.
split
(
','
)]
assert
(
len
(
fs
)
>=
4
)
op
,
target
,
precision
,
layout
,
__
,
alias
=
fs
[:
6
]
alias
=
alias
.
replace
(
')'
,
''
)
op
,
target
,
precision
,
layout
=
fields
[:
4
]
alias
=
fields
[
-
1
]
key
=
"USE_LITE_KERNEL(%s, %s, %s, %s, %s);"
%
(
key
=
"USE_LITE_KERNEL(%s, %s, %s, %s, %s);"
%
(
op
,
target
,
precision
,
layout
,
alias
)
op
,
target
,
precision
,
layout
,
alias
)
out_lines
.
append
(
key
)
out_lines
.
append
(
key
)
with
open
(
dest_path
,
'w'
)
as
f
:
with
open
(
dest_path
,
'w'
)
as
f
:
logging
.
info
(
"write kernel list to %s"
%
dest_path
)
logging
.
info
(
"write kernel list to %s"
%
dest_path
)
f
.
write
(
'
\n
'
.
join
(
out_lines
))
f
.
write
(
'
\n
'
.
join
(
out_lines
))
lite/tools/cmake_tools/parse_op_registry.py
浏览文件 @
d85fcc1f
...
@@ -25,8 +25,12 @@ out_lines = [
...
@@ -25,8 +25,12 @@ out_lines = [
''
,
''
,
]
]
lines
=
set
()
with
open
(
ops_list_path
)
as
f
:
with
open
(
ops_list_path
)
as
f
:
for
line
in
f
:
for
line
in
f
:
lines
.
add
(
line
.
strip
())
for
line
in
lines
:
path
=
line
.
strip
()
path
=
line
.
strip
()
with
open
(
path
)
as
g
:
with
open
(
path
)
as
g
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录