CMakeLists.txt 3.2 KB
Newer Older
1 2 3 4
set(kernel_declare_file ${PADDLE_BINARY_DIR}/paddle/phi/kernels/declarations.h.tmp CACHE INTERNAL "declarations.h file")
set(kernel_declare_file_final ${PADDLE_BINARY_DIR}/paddle/phi/kernels/declarations.h)
file(WRITE ${kernel_declare_file} "// Generated by the paddle/phi/kernels/CMakeLists.txt.  DO NOT EDIT!\n\n#pragma once\n\n")
file(APPEND ${kernel_declare_file} "#include \"paddle/phi/core/kernel_registry.h\"\n\n")
5

6
# phi functors and functions called by kernels
C
Chen Weihang 已提交
7
add_subdirectory(funcs)
C
Chen Weihang 已提交
8

9 10
# phi depends all phi kernel targets
set_property(GLOBAL PROPERTY PHI_KERNELS "")
11

12
# [ 1. Common kernel compilation dependencies ]
13
set(COMMON_KERNEL_DEPS dense_tensor sparse_coo_tensor sparse_csr_tensor kernel_context kernel_factory arg_map_context convert_utils lod_utils custom_kernel)
H
hong 已提交
14
set(COMMON_KERNEL_DEPS ${COMMON_KERNEL_DEPS} eigen_function blas math_function im2col vol2col concat_and_split_functor softmax)
15
# remove this dep after removing fluid deps on tensor creation
16
set(COMMON_KERNEL_DEPS ${COMMON_KERNEL_DEPS} phi_api_utils)
C
Chen Weihang 已提交
17
set(COMMON_KERNEL_DEPS ${COMMON_KERNEL_DEPS} infermeta)
18

19 20 21 22 23 24 25 26 27
# [ 2. Kernels that most kernels depend on ]
# There are a few kernels that are very basic operations, and most of the
# kernels depend on these kernels.
set(COMMON_BAISC_KERNELS empty_kernel full_kernel)
kernel_library(empty_kernel DEPS ${COMMON_KERNEL_DEPS})
kernel_library(full_kernel DEPS ${COMMON_KERNEL_DEPS} empty_kernel)

# [ 3. Kernels with special dependencies ]
# Some kernels depend on some targets that are not commonly used.
28 29
# These targets are not suitable for common dependencies.
# In this case, you need to manually generate them here.
30
set(MANUAL_BUILD_KERNELS math_kernel softmax_kernel softmax_grad_kernel triangular_solve_grad_kernel maxout_kernel maxout_grad_kernel put_along_axis_kernel put_along_axis_grad_kernel take_along_axis_kernel take_along_axis_grad_kernel eigh_kernel segment_pool_kernel segment_pool_grad_kernel)
31
kernel_library(math_kernel DEPS ${COMMON_KERNEL_DEPS} cast_kernel copy_kernel)
32 33
kernel_library(softmax_kernel DEPS ${COMMON_KERNEL_DEPS} softmax)
kernel_library(softmax_grad_kernel DEPS ${COMMON_KERNEL_DEPS} softmax)
34
kernel_library(triangular_solve_grad_kernel DEPS ${COMMON_KERNEL_DEPS} matrix_reduce)
35 36 37 38 39 40
kernel_library(maxout_kernel DEPS ${COMMON_KERNEL_DEPS} maxouting)
kernel_library(maxout_grad_kernel DEPS ${COMMON_KERNEL_DEPS} maxouting)
kernel_library(put_along_axis_kernel DEPS ${COMMON_KERNEL_DEPS} gather_scatter_kernel)
kernel_library(put_along_axis_grad_kernel DEPS ${COMMON_KERNEL_DEPS} gather_scatter_kernel)
kernel_library(take_along_axis_kernel DEPS ${COMMON_KERNEL_DEPS} gather_scatter_kernel)
kernel_library(take_along_axis_grad_kernel DEPS ${COMMON_KERNEL_DEPS} gather_scatter_kernel)
41
kernel_library(eigh_kernel DEPS ${COMMON_KERNEL_DEPS} lapack_function)
42 43
kernel_library(segment_pool_kernel DEPS ${COMMON_KERNEL_DEPS} segment_pooling)
kernel_library(segment_pool_grad_kernel DEPS ${COMMON_KERNEL_DEPS} segment_pooling)
44

45 46
# 4. auto parse and build kernel targets by cmake
register_kernels(EXCLUDES ${COMMON_BAISC_KERNELS} ${MANUAL_BUILD_KERNELS} DEPS ${COMMON_KERNEL_DEPS} ${COMMON_BAISC_KERNELS} )
47

48
# phi sparse kernels
49
add_subdirectory(sparse)
50 51

copy_if_different(${kernel_declare_file} ${kernel_declare_file_final})