CMakeLists.txt 16.0 KB
Newer Older
L
Luo Tao 已提交
1
file(GLOB GENERAL_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*_op.cc")
2
string(REPLACE "_mkldnn" "" GENERAL_OPS "${GENERAL_OPS}")
L
Luo Tao 已提交
3
string(REPLACE ".cc" "" GENERAL_OPS "${GENERAL_OPS}")
4
list(REMOVE_DUPLICATES GENERAL_OPS)
5
set(DEPS_OPS "")
6 7
set(pybind_file ${PADDLE_BINARY_DIR}/paddle/fluid/pybind/pybind.h)
file(WRITE ${pybind_file} "// Generated by the paddle/fluid/operator/CMakeLists.txt.  DO NOT EDIT!\n\n")
8 9

set(PART_CUDA_KERNEL_FILES)
Y
Yu Yang 已提交
10 11 12 13 14 15
function(op_library TARGET)
    # op_library is a function to create op library. The interface is same as
    # cc_library. But it handle split GPU/CPU code and link some common library
    # for ops.
    set(cc_srcs)
    set(cu_srcs)
S
sabreshao 已提交
16 17
    set(hip_cu_srcs)
    set(miopen_hip_cc_srcs)
18
    set(cu_cc_srcs)
C
chengduoZH 已提交
19
    set(cudnn_cu_cc_srcs)
C
chengduoZH 已提交
20
    set(CUDNN_FILE)
21 22
    set(mkldnn_cc_srcs)
    set(MKLDNN_FILE)
Y
update  
Yancey1989 已提交
23
    set(op_common_deps operator op_registry math_function)
Y
Yu Yang 已提交
24 25 26
    set(options "")
    set(oneValueArgs "")
    set(multiValueArgs SRCS DEPS)
L
Luo Tao 已提交
27
    set(pybind_flag 0)
Y
Yu Yang 已提交
28 29 30
    cmake_parse_arguments(op_library "${options}" "${oneValueArgs}"
            "${multiValueArgs}" ${ARGN})

31 32 33 34
    list(LENGTH op_library_SRCS op_library_SRCS_len)
    if (${op_library_SRCS_len} EQUAL 0)
        if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.cc)
            list(APPEND cc_srcs ${TARGET}.cc)
Y
Yu Yang 已提交
35
        endif()
36 37 38
        if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.cu.cc)
            list(APPEND cu_cc_srcs ${TARGET}.cu.cc)
        endif()
39
        if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.cu)
40
            list(APPEND cu_srcs ${TARGET}.cu)
41
        endif()
42 43 44 45 46 47
        if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.part.cu)
            set(PART_CUDA_KERNEL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.part.cu
                    ${PART_CUDA_KERNEL_FILES} PARENT_SCOPE)
            list(APPEND cu_srcs ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.part.cu)
        endif()

S
sabreshao 已提交
48 49 50
        if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.hip.cu)
            list(APPEND hip_cu_srcs ${TARGET}.hip.cu)
        endif()
C
chengduoZH 已提交
51 52 53 54
        string(REPLACE "_op" "_cudnn_op" CUDNN_FILE "${TARGET}")
        if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CUDNN_FILE}.cu.cc)
            list(APPEND cudnn_cu_cc_srcs ${CUDNN_FILE}.cu.cc)
        endif()
S
sabreshao 已提交
55 56 57 58 59 60
        if(WITH_AMD_GPU)
            string(REPLACE "_op" "_miopen_op" MIOPEN_FILE "${TARGET}")
            if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${MIOPEN_FILE}.hip.cc)
                list(APPEND miopen_hip_cc_srcs ${MIOPEN_FILE}.hip.cc)
            endif()
        endif()
61 62 63 64 65 66
        if(WITH_MKLDNN)
            string(REPLACE "_op" "_mkldnn_op" MKLDNN_FILE "${TARGET}")
            if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${MKLDNN_FILE}.cc)
                list(APPEND mkldnn_cc_srcs ${MKLDNN_FILE}.cc)
            endif()
        endif()
67 68
    else()
        foreach(src ${op_library_SRCS})
S
sabreshao 已提交
69 70 71
            if (${src} MATCHES ".*\\.hip.cu$")
                list(APPEND hip_cu_srcs ${src})
            elseif (${src} MATCHES ".*\\.cu$")
72
                list(APPEND cu_srcs ${src})
C
chengduoZH 已提交
73 74
            elseif(${src} MATCHES ".*_cudnn_op.cu.cc$")
                list(APPEND cudnn_cu_cc_srcs ${src})
S
sabreshao 已提交
75 76
            elseif(WITH_AMD_GPU AND ${src} MATCHES ".*_miopen_op.hip.cc$")
                list(APPEND miopen_hip_cc_srcs ${src})
77 78
            elseif(WITH_MKLDNN AND ${src} MATCHES ".*_mkldnn_op.cc$")
                list(APPEND mkldnn_cc_srcs ${src})
79 80
            elseif(${src} MATCHES ".*\\.cu.cc$")
                list(APPEND cu_cc_srcs ${src})
81 82 83 84 85 86 87
            elseif(${src} MATCHES ".*\\.cc$")
                list(APPEND cc_srcs ${src})
            else()
                message(FATAL_ERROR "${TARGET} Source file ${src} should only be .cc or .cu")
            endif()
        endforeach()
    endif()
Y
Yu Yang 已提交
88 89 90 91 92

    list(LENGTH cc_srcs cc_srcs_len)
    if (${cc_srcs_len} EQUAL 0)
        message(FATAL_ERROR "The op library ${TARGET} should contains at least one .cc file")
    endif()
D
dzhwinter 已提交
93
    if (WIN32)
D
dzhwinter 已提交
94 95 96
    # remove windows unsupported op, because windows has no nccl, no warpctc such ops.
    foreach(windows_unsupport_op "nccl_op" "gen_nccl_id_op" "warpctc_op" "hierarchical_sigmoid_op"
     "crf_decoding_op" "select_op" "lstmp_op" "gru_op" "fusion_gru_op" "lstm_op" "fusion_lstm_op" "cumsum_op"
P
peizhilin 已提交
97 98
      "fusion_seqconv_eltadd_relu_op" "channel_send_op" "channel_create_op" "channel_close_op" "channel_recv_op"
            "fusion_seqexpand_concat_fc_op" "attention_lstm_op" "fused_embedding_fc_lstm_op" "fc_op")
D
dzhwinter 已提交
99 100 101 102 103
        if ("${TARGET}" STREQUAL "${windows_unsupport_op}")
          return()
        endif()
    endforeach()
    endif(WIN32)
D
dzhwinter 已提交
104
    set(OP_LIBRARY ${TARGET} ${OP_LIBRARY} PARENT_SCOPE)
D
dzhwinter 已提交
105

106 107 108 109
    list(LENGTH op_library_DEPS op_library_DEPS_len)
    if (${op_library_DEPS_len} GREATER 0)
        set(DEPS_OPS ${TARGET} ${DEPS_OPS} PARENT_SCOPE)
    endif()
Y
Yu Yang 已提交
110
    if (WITH_GPU)
111
        nv_library(${TARGET} SRCS ${cc_srcs} ${cu_cc_srcs} ${cudnn_cu_cc_srcs} ${mkldnn_cc_srcs} ${cu_srcs} DEPS ${op_library_DEPS}
Y
Yu Yang 已提交
112
                ${op_common_deps})
113
    elseif (WITH_AMD_GPU)
S
sabreshao 已提交
114 115
        hip_library(${TARGET} SRCS ${cc_srcs} ${hip_cu_srcs} ${miopen_hip_cc_srcs} ${mkldnn_cc_srcs} DEPS ${op_library_DEPS}
                ${op_common_deps})
Y
Yu Yang 已提交
116
    else()
117 118
        cc_library(${TARGET} SRCS ${cc_srcs} ${mkldnn_cc_srcs} DEPS ${op_library_DEPS}
            ${op_common_deps})
Y
Yu Yang 已提交
119
    endif()
L
Luo Tao 已提交
120

121
    # Define operators that don't need pybind here.
N
nhzlx 已提交
122 123
    foreach(manual_pybind_op "compare_op" "logical_op" "nccl_op"
"tensor_array_read_write_op" "tensorrt_engine_op")
124 125 126 127
        if ("${TARGET}" STREQUAL "${manual_pybind_op}")
            set(pybind_flag 1)
        endif()
    endforeach()
Q
qijun 已提交
128

S
sabreshao 已提交
129
    # The registration of USE_OP, please refer to paddle/fluid/framework/op_registry.h.
130 131
    # Note that it's enough to just adding one operator to pybind in a *_op.cc file.
    # And for detail pybind information, please see generated paddle/pybind/pybind.h.
132
    file(READ ${TARGET}.cc TARGET_CONTENT)
Y
Yang Yang 已提交
133 134
    string(REGEX MATCH "REGISTER_OPERATOR\\(.*REGISTER_OPERATOR\\(" multi_register "${TARGET_CONTENT}")
    string(REGEX MATCH "REGISTER_OPERATOR\\([a-z0-9_]*," one_register "${multi_register}")
135 136 137
    if (one_register STREQUAL "")
        string(REPLACE "_op" "" TARGET "${TARGET}")
    else ()
Y
Yang Yang 已提交
138
        string(REPLACE "REGISTER_OPERATOR(" "" TARGET "${one_register}")
139
        string(REPLACE "," "" TARGET "${TARGET}")
Y
Yu Yang 已提交
140 141
    endif()

L
Luo Tao 已提交
142
    # pybind USE_NO_KERNEL_OP
T
typhoonzero 已提交
143
    # HACK: if REGISTER_OP_CPU_KERNEL presents the operator must have kernel
T
typhoonzero 已提交
144
    string(REGEX MATCH "REGISTER_OP_CPU_KERNEL" regex_result "${TARGET_CONTENT}")
L
Luo Tao 已提交
145 146 147 148 149 150 151 152
    string(REPLACE "_op" "" TARGET "${TARGET}")
    if (${pybind_flag} EQUAL 0 AND regex_result STREQUAL "")
        file(APPEND ${pybind_file} "USE_NO_KERNEL_OP(${TARGET});\n")
        set(pybind_flag 1)
    endif()

    # pybind USE_CPU_ONLY_OP
    list(LENGTH cu_srcs cu_srcs_len)
153
    list(LENGTH cu_cc_srcs cu_cc_srcs_len)
154
    list(LENGTH mkldnn_cc_srcs mkldnn_cc_srcs_len)
S
sabreshao 已提交
155 156 157 158
    list(LENGTH hip_cu_srcs hip_cu_srcs_len)
    list(LENGTH miopen_hip_cc_srcs miopen_hip_cc_srcs_len)
    if (${pybind_flag} EQUAL 0 AND ${mkldnn_cc_srcs_len} EQUAL 0 AND ${cu_srcs_len} EQUAL 0 AND ${cu_cc_srcs_len} EQUAL 0 AND
        ${hip_cu_srcs_len} EQUAL 0 AND ${miopen_hip_cc_srcs_len} EQUAL 0)
L
Luo Tao 已提交
159 160 161 162
        file(APPEND ${pybind_file} "USE_CPU_ONLY_OP(${TARGET});\n")
        set(pybind_flag 1)
    endif()

C
chengduoZH 已提交
163 164
    # pybind USE_OP_DEVICE_KERNEL for CUDNN
    list(LENGTH cudnn_cu_cc_srcs cudnn_cu_cc_srcs_len)
C
chengduoZH 已提交
165
    if (WITH_GPU AND ${cudnn_cu_cc_srcs_len} GREATER 0)
C
chengduoZH 已提交
166 167 168
        file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${TARGET}, CUDNN);\n")
    endif()

S
sabreshao 已提交
169 170 171 172 173
    # pybind USE_OP_DEVICE_KERNEL for MIOPEN
    if (WITH_AMD_GPU AND ${miopen_hip_cc_srcs_len} GREATER 0)
        file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${TARGET}, MIOPEN);\n")
    endif()

174 175
    # pybind USE_OP_DEVICE_KERNEL for MKLDNN
    if (WITH_MKLDNN AND ${mkldnn_cc_srcs_len} GREATER 0)
176 177 178 179
      # Append first implemented MKLDNN activation operator
      if (${MKLDNN_FILE} STREQUAL "activation_mkldnn_op")
        file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(relu, MKLDNN);\n")
      else()
180
        file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${TARGET}, MKLDNN);\n")
181
      endif()
182 183
    endif()

L
Luo Tao 已提交
184 185
    # pybind USE_OP
    if (${pybind_flag} EQUAL 0)
D
dzhwinter 已提交
186 187 188
      # NOTE(*): activation use macro to regist the kernels, set use_op manually.
      if(${TARGET} STREQUAL "activation")
        file(APPEND ${pybind_file} "USE_OP(relu);\n")
189 190
      elseif(${TARGET} STREQUAL "fake_dequantize")
        file(APPEND ${pybind_file} "USE_OP(fake_dequantize_max_abs);\n")
191 192
      elseif(${TARGET} STREQUAL "fake_quantize")
        file(APPEND ${pybind_file} "USE_OP(fake_quantize_abs_max);\n")
193 194
      elseif(${TARGET} STREQUAL "tensorrt_engine_op")
          message(STATUS "Pybind skips [tensorrt_engine_op], for this OP is only used in inference")
T
tensor-tang 已提交
195 196 197
      elseif(${TARGET} STREQUAL "fc")
        # HACK: fc only have mkldnn and cpu, which would mismatch the cpu only condition
        file(APPEND ${pybind_file} "USE_CPU_ONLY_OP(${TARGET});\n")
D
dzhwinter 已提交
198
      else()
L
Luo Tao 已提交
199
        file(APPEND ${pybind_file} "USE_OP(${TARGET});\n")
D
dzhwinter 已提交
200
      endif()
L
Luo Tao 已提交
201
    endif()
Y
Yu Yang 已提交
202 203
endfunction()

Q
qijun 已提交
204
add_subdirectory(math)
D
dzhwinter 已提交
205
if (NOT WIN32)
D
Dong Zhihong 已提交
206
add_subdirectory(nccl)
L
Luo Tao 已提交
207 208
if(WITH_GPU)
    op_library(nccl_op DEPS nccl_common)
209
    file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(ncclAllReduce);\n")
L
Luo Tao 已提交
210 211 212
else()
    set(DEPS_OPS ${DEPS_OPS} nccl_op)
endif()
D
dzhwinter 已提交
213
endif() # NOT WIN32
Q
QI JUN 已提交
214

G
gongweibao 已提交
215
set(DISTRIBUTE_DEPS "")
T
typhoonzero 已提交
216
if(WITH_DISTRIBUTE)
217
    add_subdirectory(distributed)
G
gongweibao 已提交
218 219
    set(DISTRIBUTE_DEPS "")
    if(WITH_GRPC)
X
Xin Pan 已提交
220
        set(DISTRIBUTE_DEPS sendrecvop_grpc grpc++_unsecure grpc_unsecure gpr cares zlib protobuf node)
G
gongweibao 已提交
221
    else()
X
Xin Pan 已提交
222
        set(DISTRIBUTE_DEPS sendrecvop_brpc brpc leveldb snappystream snappy protobuf ssl crypto zlib node)
G
gongweibao 已提交
223 224 225 226 227 228 229 230 231 232 233 234
        if(WITH_BRPC_RDMA)
            find_library(IBVERBS_LIBRARY NAMES ibverbs)
            ADD_LIBRARY(ibverbs SHARED IMPORTED GLOBAL)
            SET_PROPERTY(TARGET ibverbs PROPERTY IMPORTED_LOCATION ${IBVERBS_LIBRARY})


            find_library(RDMACM_LIBRARY NAMES rdmacm)
            ADD_LIBRARY(rdmacm SHARED IMPORTED GLOBAL)
            SET_PROPERTY(TARGET rdmacm PROPERTY IMPORTED_LOCATION ${RDMACM_LIBRARY})

            set(DISTRIBUTE_DEPS ${DISTRIBUTE_DEPS} ibverbs rdmacm)
        endif()
G
gongweibao 已提交
235 236
    endif()

237
    set(DISTRIBUTE_COMPILE_FLAGS "-Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor")
T
merge  
tangwei12 已提交
238
    foreach(dist_op "prefetch_op" "checkpoint_notify_op" "listen_and_serv_op" "send_op" "recv_op" "send_barrier_op" "fetch_barrier_op")
Y
Yancey1989 已提交
239 240 241
        op_library(${dist_op} DEPS ${DISTRIBUTE_DEPS})
        set_source_files_properties(${dist_op}.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
    endforeach()
242

Y
yuyang18 已提交
243 244 245
    #set_source_files_properties(send_recv_op_test.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
    #cc_test(test_send_recv SRCS send_recv_op_test.cc DEPS prefetch_op send_op
    #        listen_and_serv_op sum_op executor SERIAL)
D
dzhwinter 已提交
246
    if(WITH_GPU AND NOT WIN32)
X
Xin Pan 已提交
247
        set_source_files_properties(test_send_nccl_id.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
G
gongweibao 已提交
248
        cc_test(test_send_nccl_id SRCS test_send_nccl_id.cc DEPS listen_and_serv_op ${DISTRIBUTE_DEPS} executor SERIAL)
G
gongweibao 已提交
249 250 251 252 253
        if(WITH_GRPC)
            op_library(gen_nccl_id_op DEPS nccl_common sendrecvop_grpc)
        else()
            op_library(gen_nccl_id_op DEPS nccl_common sendrecvop_brpc)
        endif()
W
Wu Yi 已提交
254 255 256
        set_source_files_properties(gen_nccl_id_op.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
    else()
        set(DEPS_OPS ${DEPS_OPS} gen_nccl_id_op)
D
dzhwinter 已提交
257
    endif() # WITH_GPU AND NOT WIN32
258
else()
T
tangwei12 已提交
259
    set(DEPS_OPS ${DEPS_OPS}  checkpoint_notify_op prefetch_op recv_op listen_and_serv_op send_op send_barrier_op fetch_barrier_op gen_nccl_id_op)
T
typhoonzero 已提交
260 261
endif()

262
op_library(cross_entropy_op DEPS cross_entropy)
S
sneaxiy 已提交
263 264
if(WITH_GPU)
  op_library(softmax_with_cross_entropy_op DEPS cross_entropy softmax cub)
265
  op_library(sequence_softmax_op DEPS cub)
S
sneaxiy 已提交
266 267 268 269
else()
  op_library(softmax_with_cross_entropy_op DEPS cross_entropy softmax)
endif()

270
op_library(softmax_op DEPS softmax)
271
if (WITH_GPU AND TENSORRT_FOUND)
272
    op_library(tensorrt_engine_op DEPS tensorrt_engine tensorrt_converter)
N
nhzlx 已提交
273
    file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(tensorrt_engine);\n")
274
    nv_test(test_tensorrt_engine_op SRCS tensorrt_engine_op_test.cc
275
      DEPS tensorrt_engine_op
276
      analysis)
277 278
else()
    set(DEPS_OPS ${DEPS_OPS} tensorrt_engine_op)
279
endif()
M
minqiyang 已提交
280
op_library(hash_op DEPS xxhash)
M
minqiyang 已提交
281
op_library(clip_by_norm_op DEPS selected_rows_functor selected_rows)
Q
QI JUN 已提交
282 283
op_library(sum_op DEPS selected_rows_functor)
op_library(sgd_op DEPS selected_rows_functor)
Y
Yan Chunwei 已提交
284
op_library(print_op DEPS lod_tensor)
Q
QI JUN 已提交
285
op_library(adagrad_op DEPS selected_rows_functor)
W
wanghaox 已提交
286
op_library(maxout_op DEPS maxouting)
S
sweetsky0901 已提交
287
op_library(unpool_op DEPS unpooling)
288
op_library(pool_op DEPS pooling)
C
chengduoZH 已提交
289
op_library(pool_with_index_op DEPS pooling)
290 291 292 293
op_library(lod_rank_table_op DEPS lod_rank_table)
op_library(lod_tensor_to_array_op DEPS lod_rank_table_op)
op_library(array_to_lod_tensor_op DEPS lod_rank_table_op)
op_library(max_sequence_len_op DEPS lod_rank_table)
C
chengduoZH 已提交
294
op_library(sequence_conv_op DEPS context_project)
295
op_library(sequence_pool_op DEPS sequence_pooling)
D
dzhwinter 已提交
296
if (NOT WIN32)
C
chengduo 已提交
297 298 299 300
    op_library(lstm_op DEPS sequence2batch lstm_compute)
    op_library(hierarchical_sigmoid_op DEPS matrix_bit_code)
    op_library(lstmp_op DEPS sequence2batch lstm_compute)
    op_library(gru_op DEPS sequence2batch gru_compute)
D
dzhwinter 已提交
301
endif(NOT WIN32)
302
op_library(recurrent_op DEPS executor)
C
chengduoZH 已提交
303
op_library(warpctc_op DEPS dynload_warpctc sequence_padding sequence_scale)
C
chengduoZH 已提交
304
op_library(cos_sim_op DEPS cos_sim_functor)
Y
Yang Yang 已提交
305
op_library(parallel_do_op DEPS executor)
306
op_library(unsqueeze_op DEPS reshape_op)
Y
yuyang18 已提交
307
op_library(squeeze_op DEPS reshape_op)
B
Bai Yifan 已提交
308
op_library(flatten_op DEPS reshape_op)
F
fengjiayi 已提交
309
op_library(sequence_pad_op DEPS sequence_padding)
D
dzhwinter 已提交
310
op_library(unstack_op DEPS stack_op)
311
op_library(fake_quantize_op DEPS memory)
P
peizhilin 已提交
312
if (NOT WIN32)
T
tensor-tang 已提交
313
op_library(crf_decoding_op DEPS jit_kernel)
314
op_library(fusion_lstm_op DEPS jit_kernel)
P
peizhilin 已提交
315
endif(NOT WIN32)
316
if (WITH_GPU)
317
    op_library(conv_op DEPS vol2col depthwise_conv im2col)
318
    op_library(layer_norm_op DEPS cub)
319
    op_library(reduce_mean_op DEPS cub)
320
    op_library(affine_channel_op DEPS cub)
321
else()
322
    op_library(conv_op DEPS vol2col im2col)
323
endif()
324
op_library(conv_transpose_op DEPS vol2col im2col)
325

武毅 已提交
326 327 328
# FIXME(typhoonzero): save/load depends lodtensor serialization functions
op_library(save_op DEPS lod_tensor)
op_library(load_op DEPS lod_tensor)
329 330
op_library(save_combine_op DEPS lod_tensor)
op_library(load_combine_op DEPS lod_tensor)
C
chengduo 已提交
331
op_library(concat_op DEPS concat_and_split)
P
peizhilin 已提交
332
op_library(tensor_array_to_tensor_op DEPS concat_op)
武毅 已提交
333

334
list(REMOVE_ITEM GENERAL_OPS ${DEPS_OPS})
335

L
Luo Tao 已提交
336
foreach(src ${GENERAL_OPS})
337
    op_library(${src})
L
Luo Tao 已提交
338
endforeach()
339

340
file(APPEND ${pybind_file} "USE_OP(less_than);\nUSE_OP(logical_and);\nUSE_NO_KERNEL_OP(read_from_array);\n")
341 342


D
dzhwinter 已提交
343
if (NOT WIN32)
Y
FIX CI  
Yu Yang 已提交
344
add_subdirectory(reader)
D
dzhwinter 已提交
345
endif(NOT WIN32)
Y
FIX CI  
Yu Yang 已提交
346 347 348
foreach(src ${READER_LIBRARY})
    set(OP_LIBRARY ${src} ${OP_LIBRARY})
endforeach()
349

B
baiyf 已提交
350 351 352 353 354
add_subdirectory(detection)
foreach(src ${DETECTION_LIBRARY})
    set(OP_LIBRARY ${src} ${OP_LIBRARY})
endforeach()

L
Luo Tao 已提交
355
set(GLOB_OP_LIB ${OP_LIBRARY} CACHE INTERNAL "Global OP library")
G
gongweibao 已提交
356
set(GLOB_DISTRIBUTE_DEPS ${DISTRIBUTE_DEPS} CACHE INTERNAL "distributed dependency")
L
Luo Tao 已提交
357

358 359
cc_test(gather_test SRCS gather_test.cc DEPS tensor)
cc_test(scatter_test SRCS scatter_test.cc DEPS tensor)
Q
Qiao Longfei 已提交
360
cc_test(beam_search_decode_op_test SRCS beam_search_decode_op_test.cc DEPS lod_tensor)
Y
Yan Chunwei 已提交
361
cc_test(beam_search_op_test SRCS beam_search_op_test.cc DEPS lod_tensor beam_search_op)
Y
Yi Wang 已提交
362
cc_test(strided_memcpy_test SRCS strided_memcpy_test.cc DEPS tensor memory)
Y
Yu Yang 已提交
363
cc_test(save_load_op_test SRCS save_load_op_test.cc DEPS save_op load_op)
364
cc_test(save_load_combine_op_test SRCS save_load_combine_op_test.cc DEPS save_combine_op load_combine_op)
D
dzhwinter 已提交
365
if(NOT WIN32)
C
chengduo 已提交
366
    nv_test(nccl_op_test SRCS nccl_op_test.cu.cc DEPS nccl_op gpu_info device_context)
D
dzhwinter 已提交
367
endif()
G
gongweibao 已提交
368
nv_test(dropout_op_test SRCS dropout_op_test.cc DEPS dropout_op tensor)
369 370 371 372 373 374 375 376 377 378 379

if(WITH_GPU)
    foreach(CUDA_KERNEL_FILE ${PART_CUDA_KERNEL_FILES})
        file(READ ${CUDA_KERNEL_FILE} TARGET_CONTENT)
        string(REGEX MATCH "REGISTER_OP_CUDA_KERNEL\\(\\n?([^,]+),.*" MATCHED ${TARGET_CONTENT})
        if (MATCHED)
            string(STRIP ${CMAKE_MATCH_1} MATCHED)
            file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${MATCHED}, CUDA);\n")
        endif()
    endforeach()
endif()