CMakeLists.txt 6.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
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")
12

13
# phi functors and functions called by kernels
C
Chen Weihang 已提交
14
add_subdirectory(funcs)
C
Chen Weihang 已提交
15

16 17 18
# kernel autotune
add_subdirectory(autotune)

19 20
# phi depends all phi kernel targets
set_property(GLOBAL PROPERTY PHI_KERNELS "")
21

22
# [ 1. Common kernel compilation dependencies ]
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
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)
set(COMMON_KERNEL_DEPS
    ${COMMON_KERNEL_DEPS}
    eigen_function
    blas
    math_function
    im2col
    vol2col
    concat_and_split_functor
    selected_rows_functor)
42
# remove this dep after removing fluid deps on tensor creation
43
set(COMMON_KERNEL_DEPS ${COMMON_KERNEL_DEPS} phi_api_utils)
C
Chen Weihang 已提交
44
set(COMMON_KERNEL_DEPS ${COMMON_KERNEL_DEPS} infermeta)
45

46 47 48 49 50 51 52 53 54
# [ 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.
55 56
# These targets are not suitable for common dependencies.
# In this case, you need to manually generate them here.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
set(AUTOTUNE_KERNELS conv_kernel conv_grad_kernel conv_grad_grad_kernel
                     conv_transpose_kernel conv_transpose_grad_kernel)
set(MANUAL_BUILD_KERNELS
    ${AUTOTUNE_KERNELS}
    cross_entropy_kernel
    adam_kernel
    adamw_kernel
    deformable_conv_kernel
    deformable_conv_grad_kernel
    eigh_kernel
    gumbel_softmax_kernel
    gumbel_softmax_grad_kernel
    hierarchical_sigmoid_kernel
    hierarchical_sigmoid_grad_kernel
    matrix_power_kernel
    matrix_power_grad_kernel
    maxout_kernel
    maxout_grad_kernel
    pool_kernel
    put_along_axis_kernel
    put_along_axis_grad_kernel
    segment_pool_kernel
    segment_pool_grad_kernel
    softmax_kernel
    softmax_grad_kernel
    take_along_axis_kernel
    take_along_axis_grad_kernel
    triangular_solve_grad_kernel
    determinant_grad_kernel
    reduce_sum_kernel
    reduce_mean_kernel
    rnn_kernel
    rnn_grad_kernel
    warpctc_kernel
    warpctc_grad_kernel)
92 93 94
foreach(src ${AUTOTUNE_KERNELS})
  kernel_library(${src} DEPS ${COMMON_KERNEL_DEPS} switch_autotune)
endforeach()
95 96 97 98 99 100 101 102 103 104
kernel_library(
  adam_kernel
  DEPS
  gflags
  glog
  flags
  ${COMMON_KERNEL_DEPS}
  selected_rows_functor
  threadpool
  jit_kernel_helper)
105
kernel_library(adamw_kernel DEPS ${COMMON_KERNEL_DEPS} adam_kernel)
106 107 108 109 110 111 112 113
kernel_library(cross_entropy_kernel DEPS ${COMMON_KERNEL_DEPS} softmax
               cross_entropy)
kernel_library(deformable_conv_kernel DEPS ${COMMON_KERNEL_DEPS}
               deformable_conv_functor)
kernel_library(deformable_conv_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               deformable_conv_functor)
kernel_library(determinant_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               matrix_inverse)
F
From00 已提交
114
kernel_library(eigh_kernel DEPS ${COMMON_KERNEL_DEPS} lapack_function)
115 116 117 118
kernel_library(hierarchical_sigmoid_kernel DEPS ${COMMON_KERNEL_DEPS}
               matrix_bit_code)
kernel_library(hierarchical_sigmoid_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               matrix_bit_code)
F
From00 已提交
119 120
kernel_library(gumbel_softmax_kernel DEPS ${COMMON_KERNEL_DEPS} softmax)
kernel_library(gumbel_softmax_grad_kernel DEPS ${COMMON_KERNEL_DEPS} softmax)
121
kernel_library(reduce_sum_kernel DEPS ${COMMON_KERNEL_DEPS} cast_kernel)
122
kernel_library(reduce_mean_kernel DEPS ${COMMON_KERNEL_DEPS} cast_kernel)
F
From00 已提交
123
kernel_library(matrix_power_kernel DEPS ${COMMON_KERNEL_DEPS} matrix_inverse)
124 125
kernel_library(matrix_power_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               matrix_inverse)
126 127
kernel_library(maxout_kernel DEPS ${COMMON_KERNEL_DEPS} maxouting)
kernel_library(maxout_grad_kernel DEPS ${COMMON_KERNEL_DEPS} maxouting)
F
From00 已提交
128
kernel_library(pool_kernel DEPS ${COMMON_KERNEL_DEPS} pooling)
129 130 131 132
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)
133
kernel_library(segment_pool_kernel DEPS ${COMMON_KERNEL_DEPS} segment_pooling)
134 135
kernel_library(segment_pool_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               segment_pooling)
F
From00 已提交
136 137
kernel_library(softmax_kernel DEPS ${COMMON_KERNEL_DEPS} softmax)
kernel_library(softmax_grad_kernel DEPS ${COMMON_KERNEL_DEPS} softmax)
138 139 140 141 142 143 144 145 146 147 148 149 150 151
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)
kernel_library(triangular_solve_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               matrix_reduce)
kernel_library(rnn_kernel DEPS ${COMMON_KERNEL_DEPS} concat_and_split_functor
               lstm_compute gru_compute)
kernel_library(rnn_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               concat_and_split_functor lstm_compute gru_compute)
kernel_library(warpctc_kernel DEPS ${COMMON_KERNEL_DEPS} phi_dynload_warpctc
               sequence_padding sequence_scale)
kernel_library(warpctc_grad_kernel DEPS ${COMMON_KERNEL_DEPS}
               phi_dynload_warpctc sequence_padding sequence_scale)
152

153
# 4. auto parse and build kernel targets by cmake
154 155
register_kernels(EXCLUDES ${COMMON_BAISC_KERNELS} ${MANUAL_BUILD_KERNELS} DEPS
                 ${COMMON_KERNEL_DEPS} ${COMMON_BAISC_KERNELS})
156

157
# phi sparse kernels
158
add_subdirectory(sparse)
159 160
# phi selected_rows kernels
add_subdirectory(selected_rows)
161 162

copy_if_different(${kernel_declare_file} ${kernel_declare_file_final})
J
Jack Zhou 已提交
163 164
# For strings kernels
add_subdirectory(strings)