Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
e5c7ca48
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看板
未验证
提交
e5c7ca48
编写于
12月 26, 2021
作者:
C
Chen Weihang
提交者:
GitHub
12月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
auto parse kernel deps by include (#38438)
上级
acef85b2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
27 addition
and
8 deletion
+27
-8
cmake/pten_kernel.cmake
cmake/pten_kernel.cmake
+27
-8
未找到文件。
cmake/pten_kernel.cmake
浏览文件 @
e5c7ca48
...
...
@@ -18,7 +18,7 @@ function(kernel_declare TARGET_LIST)
file
(
READ
${
kernel_path
}
kernel_impl
)
# TODO(chenweihang): rename PT_REGISTER_CTX_KERNEL to PT_REGISTER_KERNEL
# NOTE(chenweihang): now we don't recommend to use digit in kernel name
string
(
REGEX MATCH
"(PT_REGISTER_CTX_KERNEL|PT_REGISTER_GENERAL_KERNEL)
\\
([
\t\r\n
]*[a-z_]*,"
first_registry
"
${
kernel_impl
}
"
)
string
(
REGEX MATCH
"(PT_REGISTER_CTX_KERNEL|PT_REGISTER_GENERAL_KERNEL)
\\
([
\t\r\n
]*[a-z
0-9
_]*,"
first_registry
"
${
kernel_impl
}
"
)
if
(
NOT first_registry STREQUAL
""
)
# parse the first kernel name
string
(
REPLACE
"PT_REGISTER_CTX_KERNEL("
""
kernel_name
"
${
first_registry
}
"
)
...
...
@@ -49,6 +49,9 @@ function(kernel_library TARGET)
set
(
gpu_srcs
)
set
(
xpu_srcs
)
set
(
npu_srcs
)
# parse and save the deps kerenl targets
set
(
all_srcs
)
set
(
kernel_deps
)
set
(
oneValueArgs
""
)
set
(
multiValueArgs SRCS DEPS
)
...
...
@@ -57,7 +60,6 @@ function(kernel_library TARGET)
list
(
LENGTH kernel_library_SRCS kernel_library_SRCS_len
)
# one kernel only match one impl file in each backend
# TODO(chenweihang): parse compile deps by include headers
if
(
${
kernel_library_SRCS_len
}
EQUAL 0
)
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
TARGET
}
.cc
)
list
(
APPEND common_srcs
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
TARGET
}
.cc
)
...
...
@@ -84,6 +86,23 @@ function(kernel_library TARGET)
# TODO(chenweihang): impl compile by source later
endif
()
list
(
APPEND all_srcs
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
TARGET
}
.h
)
list
(
APPEND all_srcs
${
common_srcs
}
)
list
(
APPEND all_srcs
${
cpu_srcs
}
)
list
(
APPEND all_srcs
${
gpu_srcs
}
)
list
(
APPEND all_srcs
${
xpu_srcs
}
)
foreach
(
src
${
all_srcs
}
)
file
(
READ
${
src
}
target_content
)
string
(
REGEX MATCHALL
"#include
\"
paddle\/pten\/kernels\/[a-z0-9_]+_kernel.h
\"
"
include_kernels
${
target_content
}
)
foreach
(
include_kernel
${
include_kernels
}
)
string
(
REGEX REPLACE
"#include
\"
paddle\/pten\/kernels\/"
""
kernel_name
${
include_kernel
}
)
string
(
REGEX REPLACE
".h
\"
"
""
kernel_name
${
kernel_name
}
)
list
(
APPEND kernel_deps
${
kernel_name
}
)
endforeach
()
endforeach
()
list
(
REMOVE_DUPLICATES kernel_deps
)
list
(
REMOVE_ITEM kernel_deps
${
TARGET
}
)
list
(
LENGTH common_srcs common_srcs_len
)
list
(
LENGTH cpu_srcs cpu_srcs_len
)
list
(
LENGTH gpu_srcs gpu_srcs_len
)
...
...
@@ -95,11 +114,11 @@ function(kernel_library TARGET)
# we will use this implementation and will not adopt the implementation
# under specific devices
if
(
WITH_GPU
)
nv_library
(
${
TARGET
}
SRCS
${
common_srcs
}
DEPS
${
kernel_library_DEPS
}
)
nv_library
(
${
TARGET
}
SRCS
${
common_srcs
}
DEPS
${
kernel_library_DEPS
}
${
kernel_deps
}
)
elseif
(
WITH_ROCM
)
hip_library
(
${
TARGET
}
SRCS
${
common_srcs
}
DEPS
${
kernel_library_DEPS
}
)
hip_library
(
${
TARGET
}
SRCS
${
common_srcs
}
DEPS
${
kernel_library_DEPS
}
${
kernel_deps
}
)
else
()
cc_library
(
${
TARGET
}
SRCS
${
common_srcs
}
DEPS
${
kernel_library_DEPS
}
)
cc_library
(
${
TARGET
}
SRCS
${
common_srcs
}
DEPS
${
kernel_library_DEPS
}
${
kernel_deps
}
)
endif
()
else
()
# If the kernel has a header file declaration, but no corresponding
...
...
@@ -110,15 +129,15 @@ function(kernel_library TARGET)
else
()
if
(
WITH_GPU
)
if
(
${
cpu_srcs_len
}
GREATER 0 OR
${
gpu_srcs_len
}
GREATER 0
)
nv_library
(
${
TARGET
}
SRCS
${
cpu_srcs
}
${
gpu_srcs
}
DEPS
${
kernel_library_DEPS
}
)
nv_library
(
${
TARGET
}
SRCS
${
cpu_srcs
}
${
gpu_srcs
}
DEPS
${
kernel_library_DEPS
}
${
kernel_deps
}
)
endif
()
elseif
(
WITH_ROCM
)
if
(
${
cpu_srcs_len
}
GREATER 0 OR
${
gpu_srcs_len
}
GREATER 0
)
hip_library
(
${
TARGET
}
SRCS
${
cpu_srcs
}
${
gpu_srcs
}
DEPS
${
kernel_library_DEPS
}
)
hip_library
(
${
TARGET
}
SRCS
${
cpu_srcs
}
${
gpu_srcs
}
DEPS
${
kernel_library_DEPS
}
${
kernel_deps
}
)
endif
()
else
()
if
(
${
cpu_srcs_len
}
GREATER 0 OR
${
xpu_srcs_len
}
GREATER 0 OR
${
npu_srcs_len
}
GREATER 0
)
cc_library
(
${
TARGET
}
SRCS
${
cpu_srcs
}
${
xpu_srcs
}
${
npu_srcs
}
DEPS
${
kernel_library_DEPS
}
)
cc_library
(
${
TARGET
}
SRCS
${
cpu_srcs
}
${
xpu_srcs
}
${
npu_srcs
}
DEPS
${
kernel_library_DEPS
}
${
kernel_deps
}
)
endif
()
endif
()
endif
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录