Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
飞不过沧海
Paddle
提交
5f6038ff
P
Paddle
项目概览
飞不过沧海
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5f6038ff
编写于
3月 25, 2022
作者:
W
Wilber
提交者:
GitHub
3月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
infrt update phi gpu register. (#40866)
* update register every make. * fix * update
上级
be5918e0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
73 addition
and
6 deletion
+73
-6
paddle/infrt/kernel/phi/CMakeLists.txt
paddle/infrt/kernel/phi/CMakeLists.txt
+5
-4
tools/infrt/get_phi_kernel_function.sh
tools/infrt/get_phi_kernel_function.sh
+45
-1
tools/infrt/get_phi_kernel_info.py
tools/infrt/get_phi_kernel_info.py
+23
-1
未找到文件。
paddle/infrt/kernel/phi/CMakeLists.txt
浏览文件 @
5f6038ff
...
...
@@ -17,18 +17,19 @@ set(wrapped_infermeta_source_file ${CMAKE_SOURCE_DIR}/paddle/phi/infermeta/gener
add_custom_command
(
OUTPUT
${
infrt_register_phi_kernels_gen_source_file
}
COMMAND sh
${
infrt_register_phi_kernels_gen_file
}
DEPENDS
${
wrapped_infermeta_header_file
}
${
wrapped_infermeta_source_file
}
COMMAND
ba
sh
${
infrt_register_phi_kernels_gen_file
}
DEPENDS
wrapped_infermeta
VERBATIM
)
add_custom_target
(
infrt_register_phi_kernel
COMMAND sh
${
infrt_register_phi_kernels_gen_file
}
DEPENDS
${
wrapped_infermeta_header_file
}
${
wrapped_infermeta_source_file
}
COMMAND
ba
sh
${
infrt_register_phi_kernels_gen_file
}
DEPENDS
wrapped_infermeta
COMMENT
"infrt generate
${
infrt_register_phi_kernels_gen_source_file
}
"
VERBATIM
)
cc_library
(
infrt_naive SRCS infershaped/infershaped_kernel_launcher.cc
infershaped/infershaped_kernel_launchers.cc
DEPS phi wrapped_infermeta
)
add_dependencies
(
infrt_naive infrt_register_phi_kernel
)
cc_test_tiny
(
test_infrt_infershape_launchers SRCS
infershaped/infershape_launchers_test.cc DEPS infrt
)
tools/infrt/get_phi_kernel_function.sh
浏览文件 @
5f6038ff
...
...
@@ -21,9 +21,10 @@
set
-e
#step 1:get kernel registered info
# The shell script has some problem when register with macro, such as in `activation_kernel.c*`
kernel_register_info_file
=
`
mktemp
`
PADDLE_ROOT
=
"
$(
cd
"
$(
dirname
"
$0
"
)
/../../"
&&
pwd
)
"
unset
GREP_OPTIONS
&&
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"*.c*"
\
unset
GREP_OPTIONS
&&
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"*.c*"
|
grep
-v
"activation_kernel.c*"
\
| xargs
sed
-e
'/PD_REGISTER_\(GENERAL_\)\?KERNEL(/,/)/!d'
\
|
awk
'BEGIN { RS="{" }{ gsub(/\n /,""); print $0 }'
\
|
grep
PD_REGISTER
\
...
...
@@ -31,6 +32,49 @@ unset GREP_OPTIONS && find ${PADDLE_ROOT}/paddle/phi/kernels -name "*.c*" \
|
sort
-u
|
awk
'{gsub(/phi::/,"");gsub(/paddle::platform::/,"");gsub(/dtype::/,"");gsub(/paddle::/,"");print $0}'
\
|
grep
-v
"_grad"
>
$kernel_register_info_file
# handle `activation_kernel.cc` case by case.
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"activation_kernel.cc"
| xargs
sed
-e
'/PD_REGISTER_KERNEL(relu/,/)/!d'
\
|
awk
'BEGIN { RS="{" }{ gsub(/\n /,""); print $0 }'
|
grep
PD_REGISTER_KERNEL
\
|
awk
-F
",|
\(
|
\)
"
'{gsub(/ /,"");$1="";print}'
\
|
sort
-u
|
awk
'{gsub(/phi::/,"");gsub(/paddle::platform::/,"");gsub(/dtype::/,"");gsub(/paddle::/,"");print $0}'
\
|
grep
-v
"_grad"
>>
$kernel_register_info_file
act_temp
=
$(
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"activation_kernel.cc"
| xargs
sed
-e
'/PD_REGISTER_KERNEL(name/,/)/!d'
\
|
awk
'BEGIN { RS="{" }{ gsub(/\n /,""); print $0 }'
|
grep
-E
"PD_REGISTER_(GENERAL_)?KERNEL"
\
|
awk
-F
",|
\(
|
\)
"
'{gsub(/ /,"");gsub(/\\/,"");$1="";print}'
|
sort
-u
\
|
awk
'{gsub(/phi::/,"");gsub(/paddle::platform::/,"");gsub(/dtype::/,"");gsub(/paddle::/,"");print $0}'
\
|
grep
-v
"_grad"
)
all_act_arg
=
$(
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"activation_kernel.cc"
| xargs
sed
-e
'/PD_REGISTER_ACTIVATION_KERNEL(/,/)/!d'
|
grep
-v
'#define'
|
grep
PD_REGISTER_ACTIVATION_KERNEL |
awk
-F
"
\(
|
\)
"
'{gsub(/ /,"");$1="";print}'
|
sed
-e
's/[ \t]*$//g'
)
for
act
in
$all_act_arg
do
name
=
${
act
%,*
}
kernel
=
$(
echo
${
act
#*,
}
|
sed
-e
's/\r//g'
)
tmp
=
${
act_temp
/name/
${
name
}}
echo
"
${
tmp
/func/
${
kernel
}}
"
>>
$kernel_register_info_file
done
# TODO(wilber): We just support cuda, not support rocm.
# handle `activation_kernel.cu` which register with macro.
# - process relu kernel.
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"activation_kernel.cu"
| xargs
sed
-e
'/PD_REGISTER_KERNEL(relu/,/)/!d'
\
|
awk
'BEGIN { RS="{" }{ gsub(/\n /,""); print $0 }'
|
awk
'NR>2'
|
grep
PD_REGISTER
\
|
awk
-F
",|
\(
|
\)
"
'{gsub(/ /,"");$1="";print}'
\
|
sort
-u
|
awk
'{gsub(/phi::/,"");gsub(/paddle::platform::/,"");gsub(/dtype::/,"");gsub(/paddle::/,"");print $0}'
\
|
grep
-v
"_grad"
>>
$kernel_register_info_file
# - process PD_REGISTER_ACTIVATION_KERNEL kernels.
act_temp
=
$(
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"activation_kernel.cu"
| xargs
sed
-e
'/PD_REGISTER_KERNEL(name/,/)/!d'
\
|
awk
'BEGIN { RS="{" }{ gsub(/\n /,""); print $0 }'
|
grep
PD_REGISTER
\
|
awk
-F
",|
\(
|
\)
"
'{gsub(/ /,"");gsub(/\\/,"");$1="";print}'
|
sort
-u
\
|
awk
'{gsub(/phi::/,"");gsub(/paddle::platform::/,"");gsub(/dtype::/,"");gsub(/paddle::/,"");print $0}'
\
|
grep
-v
"_grad"
)
all_act_arg
=
$(
find
${
PADDLE_ROOT
}
/paddle/phi/kernels
-name
"activation_kernel.cu"
| xargs
sed
-e
'/PD_REGISTER_ACTIVATION_KERNEL(/,/)/!d'
|
grep
-v
'#define'
|
grep
PD_REGISTER_ACTIVATION_KERNEL |
awk
-F
"
\(
|
\)
"
'{gsub(/ /,"");$1="";print}'
|
sed
-e
's/[ \t]*$//g'
)
for
act
in
$all_act_arg
do
name
=
${
act
%,*
}
kernel
=
$(
echo
${
act
#*,
}
|
sed
-e
's/\r//g'
)
tmp
=
${
act_temp
/name/
${
name
}}
echo
"
${
tmp
/func/
${
kernel
}}
"
>>
$kernel_register_info_file
done
#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
\
...
...
tools/infrt/get_phi_kernel_info.py
浏览文件 @
5f6038ff
...
...
@@ -56,6 +56,28 @@ def get_api_yaml_info(file_path):
def
get_kernel_info
(
file_path
):
f
=
open
(
file_path
,
"r"
)
cont
=
f
.
readlines
()
ret
=
[]
prev
=
[]
for
line
in
cont
:
info
=
line
.
strip
().
split
()
if
not
info
:
continue
if
len
(
prev
)
==
0
:
ret
.
append
(
line
.
strip
())
prev
=
info
continue
if
prev
[
0
]
==
info
[
0
]
and
prev
[
1
]
==
info
[
1
]:
ret
.
pop
()
ret
.
append
(
line
.
strip
())
prev
=
info
return
ret
def
get_infermeta_info
(
file_path
):
f
=
open
(
file_path
,
"r"
)
cont
=
f
.
readlines
()
return
[
l
.
strip
()
for
l
in
cont
if
l
.
strip
()
!=
""
]
...
...
@@ -319,7 +341,7 @@ if __name__ == "__main__":
args
=
parse_args
()
infer_meta_data
=
get_api_yaml_info
(
args
.
paddle_root_path
)
kernel_data
=
get_kernel_info
(
args
.
kernel_info_file
)
info_meta_wrap_data
=
get_
kernel
_info
(
args
.
infermeta_wrap_file
)
info_meta_wrap_data
=
get_
infermeta
_info
(
args
.
infermeta_wrap_file
)
attr_data
=
get_attr_info
(
args
.
attr_info_file
)
out
=
merge
(
infer_meta_data
,
kernel_data
,
info_meta_wrap_data
)
gen_phi_kernel_register_code
(
out
,
attr_data
,
args
.
generate_file
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录