Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a7d4ddc4
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a7d4ddc4
编写于
2月 16, 2022
作者:
S
Shang Zhizhou
提交者:
GitHub
2月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update tools for infrt build (#39552)
上级
eb3c7d00
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
70 addition
and
5 deletion
+70
-5
tools/infrt/get_pten_kernel_function.sh
tools/infrt/get_pten_kernel_function.sh
+52
-0
tools/infrt/get_pten_kernel_info.py
tools/infrt/get_pten_kernel_info.py
+18
-5
未找到文件。
paddle/scripts
/get_pten_kernel_function.sh
→
tools/infrt
/get_pten_kernel_function.sh
浏览文件 @
a7d4ddc4
...
@@ -20,9 +20,33 @@
...
@@ -20,9 +20,33 @@
set
-e
set
-e
EXIT_CODE
=
0
;
#step 1:get kernel registered info
tmp_dir
=
`
mktemp
-d
`
kernel_register_info_file
=
`
mktemp
`
PADDLE_ROOT
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../"
&&
pwd
)
"
PADDLE_ROOT
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../"
&&
pwd
)
"
unset
GREP_OPTIONS
&&
find
${
PADDLE_ROOT
}
/paddle/pten/kernels
-name
"*.c*"
\
| xargs
sed
-e
'/PT_REGISTER_\(GENERAL_\)\?KERNEL(/,/)/!d'
\
|
awk
'BEGIN { RS="{" }{ gsub(/\n /,""); print $0 }'
\
|
grep
PT_REGISTER
\
|
awk
-F
",|
\(
"
'{gsub(/ /,"");print $2, $3, $4, $5}'
\
|
sort
-u
|
awk
'{gsub(/pten::/,"");print $0}'
\
|
grep
-v
"_grad"
>
$kernel_register_info_file
#step 2:get simple general inferMeta function wrap info
temp_path
=
`
mktemp
-d
`
python3
${
PADDLE_ROOT
}
/python/paddle/utils/code_gen/wrapped_infermeta_gen.py
\
--api_yaml_path
${
PADDLE_ROOT
}
/python/paddle/utils/code_gen/api.yaml
\
--wrapped_infermeta_header_path
${
temp_path
}
/generate.h
\
--wrapped_infermeta_source_path
${
temp_path
}
/generate.cc
grep
PT_REGISTER_INFER_META_FN
${
temp_path
}
/generate.cc
\
|
awk
-F
"
\(
|,|::|
\)
"
'{print $2, $4}'
>
${
temp_path
}
/wrap_info.txt
unset
GREP_OPTIONS
&&
find
${
PADDLE_ROOT
}
/paddle/pten/kernels
-name
"*.c*"
| xargs
sed
-e
'/PT_REGISTER_\(GENERAL_\)\?KERNEL(/,/)/!d'
|
awk
'BEGIN { RS="{" }{ gsub(/\n /,""); print $0 }'
|
grep
PT_REGISTER |
awk
-F
",|
\(
"
'{gsub(/ /,"");print $2, $3, $4, $5}'
|
sort
-u
|
awk
'{gsub(/pten::/,"");print $0}'
|
grep
-v
"_grad"
#step 3: merge all infos
# @input1 => pten kernel infomation : kernel_name kernel_key(GPU/CPU, precision, layout)
# @input2 => information from api.yaml : kernel_name kernel_function_name inferMeta_function_name
# @input3 => information from wrapped_infermeta_gen : ensure the inferMeta function has
# same signature with kernel function
python3
${
PADDLE_ROOT
}
/tools/infrt/get_pten_kernel_info.py
\
--paddle_root_path
${
PADDLE_ROOT
}
\
--kernel_info_file
$kernel_register_info_file
\
--infermeta_wrap_file
${
temp_path
}
/wrap_info.txt
paddle/scripts
/get_pten_kernel_info.py
→
tools/infrt
/get_pten_kernel_info.py
浏览文件 @
a7d4ddc4
...
@@ -31,6 +31,11 @@ def parse_args():
...
@@ -31,6 +31,11 @@ def parse_args():
type
=
str
,
type
=
str
,
required
=
True
,
required
=
True
,
help
=
"kernel info file generated by get_pten_kernel_function.sh ."
)
help
=
"kernel info file generated by get_pten_kernel_function.sh ."
)
parser
.
add_argument
(
"--infermeta_wrap_file"
,
type
=
str
,
required
=
True
,
help
=
"inferMeta wrap info file ."
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
return
args
return
args
...
@@ -47,16 +52,23 @@ def get_kernel_info(file_path):
...
@@ -47,16 +52,23 @@ def get_kernel_info(file_path):
return
[
l
.
strip
()
for
l
in
cont
]
return
[
l
.
strip
()
for
l
in
cont
]
def
merge
(
infer_meta_data
,
kernel_data
):
def
merge
(
infer_meta_data
,
kernel_data
,
wrap_data
):
meta_map
=
{}
meta_map
=
{}
for
api
in
infer_meta_data
:
for
api
in
infer_meta_data
:
if
not
api
.
has_key
(
"kernel"
)
or
not
api
.
has_key
(
"infer_meta"
)
:
if
"kernel"
not
in
api
or
"infer_meta"
not
in
api
:
continue
continue
meta_map
[
api
[
"kernel"
][
"func"
]]
=
api
[
"infer_meta"
][
"func"
]
meta_map
[
api
[
"kernel"
][
"func"
]]
=
api
[
"infer_meta"
][
"func"
]
wrap_map
=
{}
for
l
in
wrap_data
:
wrap_map
[
l
.
split
()[
0
]]
=
l
.
split
()[
1
]
full_kernel_data
=
[]
full_kernel_data
=
[]
for
l
in
kernel_data
:
for
l
in
kernel_data
:
key
=
l
.
split
()[
0
]
key
=
l
.
split
()[
0
]
if
meta_map
.
has_key
(
key
):
if
key
in
meta_map
:
if
key
in
meta_map
:
full_kernel_data
.
append
((
l
+
" "
+
wrap_map
[
key
]).
split
())
else
:
full_kernel_data
.
append
((
l
+
" "
+
meta_map
[
key
]).
split
())
full_kernel_data
.
append
((
l
+
" "
+
meta_map
[
key
]).
split
())
else
:
else
:
full_kernel_data
.
append
((
l
+
" unknown"
).
split
())
full_kernel_data
.
append
((
l
+
" unknown"
).
split
())
...
@@ -68,5 +80,6 @@ if __name__ == "__main__":
...
@@ -68,5 +80,6 @@ if __name__ == "__main__":
args
=
parse_args
()
args
=
parse_args
()
infer_meta_data
=
get_api_yaml_info
(
args
.
paddle_root_path
)
infer_meta_data
=
get_api_yaml_info
(
args
.
paddle_root_path
)
kernel_data
=
get_kernel_info
(
args
.
kernel_info_file
)
kernel_data
=
get_kernel_info
(
args
.
kernel_info_file
)
out
=
merge
(
infer_meta_data
,
kernel_data
)
info_meta_wrap_data
=
get_kernel_info
(
args
.
infermeta_wrap_file
)
out
=
merge
(
infer_meta_data
,
kernel_data
,
info_meta_wrap_data
)
print
(
json
.
dumps
(
out
))
print
(
json
.
dumps
(
out
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录