Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8739497c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
8739497c
编写于
10月 21, 2022
作者:
J
JingZhuangzhuang
提交者:
GitHub
10月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add infer prune function (#47047)
* Add infer prune function * add fusion op
上级
29c9f027
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
107 addition
and
0 deletion
+107
-0
cmake/operators.cmake
cmake/operators.cmake
+55
-0
cmake/phi.cmake
cmake/phi.cmake
+32
-0
paddle/fluid/inference/CMakeLists.txt
paddle/fluid/inference/CMakeLists.txt
+8
-0
paddle/fluid/operators/CMakeLists.txt
paddle/fluid/operators/CMakeLists.txt
+5
-0
paddle/phi/kernels/CMakeLists.txt
paddle/phi/kernels/CMakeLists.txt
+7
-0
未找到文件。
cmake/operators.cmake
浏览文件 @
8739497c
...
...
@@ -611,3 +611,58 @@ function(register_operators)
endif
()
endif
()
endfunction
()
function
(
prune_pybind_h
)
set
(
op_list
${
OP_LIST
}
)
list
(
APPEND op_list
"load_combine"
)
list
(
APPEND op_list
"tensorrt_engine"
)
# add fused_op in op_list
list
(
APPEND op_list
"fc"
)
list
(
APPEND op_list
"conv2d_fusion"
)
list
(
APPEND op_list
"fusion_seqconv_eltadd_relu"
)
list
(
APPEND op_list
"fusion_seqpool_cvm_concat"
)
list
(
APPEND op_list
"fusion_gru"
)
list
(
APPEND op_list
"fusion_seqexpand_concat_fc"
)
list
(
APPEND op_list
"fusion_repeated_fc_relu"
)
list
(
APPEND op_list
"fusion_squared_mat_sub"
)
# add plugin_op in op_list
list
(
APPEND op_list
"anchor_generator"
)
file
(
STRINGS
${
pybind_file
}
op_registry_list
)
file
(
WRITE
${
pybind_file_prune
}
""
)
file
(
APPEND
${
pybind_file_prune
}
"// Generated by the paddle/fluid/operators/CMakeLists.txt. DO NOT EDIT!
\n
"
)
# add USE_OP_ITSELF for all op in op_list
foreach
(
op_name IN LISTS op_list
)
file
(
APPEND
${
pybind_file_prune
}
"USE_OP_ITSELF(
${
op_name
}
);
\n
"
)
endforeach
()
foreach
(
op_registry IN LISTS op_registry_list
)
if
(
NOT
${
op_registry
}
EQUAL
""
)
foreach
(
op_name IN LISTS op_list
)
string
(
FIND
${
op_registry
}
"(
${
op_name
}
)"
index1
)
string
(
FIND
${
op_registry
}
"(
${
op_name
}
,"
index2
)
string
(
FIND
${
op_registry
}
"USE_OP_ITSELF"
index3
)
if
(((
NOT
${
index1
}
EQUAL
"-1"
)
OR
(
NOT
${
index2
}
EQUAL
"-1"
))
AND
(
${
index3
}
EQUAL
"-1"
))
file
(
APPEND
${
pybind_file_prune
}
"
${
op_registry
}
\n
"
)
endif
()
endforeach
()
endif
()
endforeach
()
file
(
WRITE
${
pybind_file
}
""
)
file
(
STRINGS
${
pybind_file_prune
}
op_registry_list_tmp
)
foreach
(
op_name IN LISTS op_registry_list_tmp
)
if
(
NOT
${
op_name
}
EQUAL
""
)
file
(
APPEND
${
pybind_file
}
"
${
op_name
}
\n
"
)
endif
()
endforeach
()
endfunction
()
cmake/phi.cmake
浏览文件 @
8739497c
...
...
@@ -148,3 +148,35 @@ function(register_op_utils TARGET_NAME)
SRCS
${
utils_srcs
}
DEPS
${
register_op_utils_DEPS
}
)
endfunction
()
function
(
prune_declaration_h
)
set
(
kernel_list
${
KERNEL_LIST
}
)
file
(
STRINGS
${
kernel_declare_file
}
kernel_registry_list
)
file
(
WRITE
${
kernel_declare_file_prune
}
""
)
file
(
APPEND
${
kernel_declare_file_prune
}
"// Generated by the paddle/phi/kernels/CMakeLists.txt. DO NOT EDIT!
\n
"
)
file
(
APPEND
${
kernel_declare_file_prune
}
"#pragma once
\n
"
)
file
(
APPEND
${
kernel_declare_file_prune
}
"#include
\"
paddle/phi/core/kernel_registry.h
\"\n
"
)
foreach
(
kernel_registry IN LISTS kernel_registry_list
)
if
(
NOT
${
kernel_registry
}
EQUAL
""
)
foreach
(
kernel_name IN LISTS kernel_list
)
string
(
FIND
${
kernel_registry
}
"(
${
kernel_name
}
)"
index1
)
string
(
FIND
${
kernel_registry
}
"(
${
kernel_name
}
,"
index2
)
if
((
NOT
${
index1
}
EQUAL
"-1"
)
OR
(
NOT
${
index2
}
EQUAL
"-1"
))
file
(
APPEND
${
kernel_declare_file_prune
}
"
${
kernel_registry
}
\n
"
)
endif
()
endforeach
()
endif
()
endforeach
()
file
(
WRITE
${
kernel_declare_file
}
""
)
file
(
STRINGS
${
kernel_declare_file_prune
}
kernel_registry_list_tmp
)
foreach
(
kernel_registry IN LISTS kernel_registry_list_tmp
)
if
(
NOT
${
kernel_registry
}
EQUAL
""
)
file
(
APPEND
${
kernel_declare_file
}
"
${
kernel_registry
}
\n
"
)
endif
()
endforeach
()
endfunction
()
paddle/fluid/inference/CMakeLists.txt
浏览文件 @
8739497c
...
...
@@ -58,6 +58,14 @@ set(STATIC_INFERENCE_API
phi
${
mkldnn_quantizer_cfg
}
)
set
(
OP_LIST
""
CACHE STRING
"The list of operators that will be compiled"
)
set
(
KERNEL_LIST
""
CACHE STRING
"The list of phi kernels that will be compiled"
)
#windows GPU static library over the limit, so not create_static_lib, and cc_library is dummy
if
(
WIN32 AND WITH_GPU
)
cc_library
(
paddle_inference DEPS
${
fluid_modules
}
phi
${
STATIC_INFERENCE_API
}
...
...
paddle/fluid/operators/CMakeLists.txt
浏览文件 @
8739497c
...
...
@@ -8,6 +8,7 @@ add_definitions(-D_USE_MATH_DEFINES)
unset
(
GLOB_OP_LIB CACHE
)
unset
(
OP_LIBRARY CACHE
)
set
(
pybind_file
${
PADDLE_BINARY_DIR
}
/paddle/fluid/pybind/pybind.h.tmp CACHE INTERNAL
"pybind.h file"
)
set
(
pybind_file_prune
${
PADDLE_BINARY_DIR
}
/paddle/fluid/pybind/pybind.h.prune CACHE INTERNAL
"pybind.h file"
)
set
(
pybind_file_final
${
PADDLE_BINARY_DIR
}
/paddle/fluid/pybind/pybind.h
)
file
(
WRITE
${
pybind_file
}
"// Generated by the paddle/fluid/operators/CMakeLists.txt. DO NOT EDIT!
\n\n
"
)
...
...
@@ -258,3 +259,7 @@ copy_if_different(${pybind_file} ${pybind_file_final})
if
(
WITH_CUSTOM_DEVICE
)
cc_library
(
custom_device_common_op_registry SRCS custom_device_common_op_registry.cc DEPS operator
)
endif
()
if
(
NOT
"
${
OP_LIST
}
"
STREQUAL
""
)
prune_pybind_h
()
endif
()
paddle/phi/kernels/CMakeLists.txt
浏览文件 @
8739497c
...
...
@@ -9,6 +9,9 @@ file(
)
file
(
APPEND
${
kernel_declare_file
}
"#include
\"
paddle/phi/core/kernel_registry.h
\"\n\n
"
)
set
(
kernel_declare_file_prune
${
PADDLE_BINARY_DIR
}
/paddle/phi/kernels/declarations.h.prune
CACHE INTERNAL
"declarations.h file"
)
# phi functors and functions called by kernels
add_subdirectory
(
funcs
)
...
...
@@ -171,3 +174,7 @@ if(WITH_XPU)
endif
()
set_property
(
GLOBAL PROPERTY PHI_KERNELS
${
ADD_PHI_KERNELS
}
)
if
(
NOT
"
${
KERNEL_LIST
}
"
STREQUAL
""
)
prune_declaration_h
()
endif
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录