CMakeLists.txt 3.4 KB
Newer Older
W
wopeizl 已提交
1
add_subdirectory(detail)
2

3
function(math_library TARGET)
M
minqiyang 已提交
4 5
    # math_library is a function to create math library.
    # The interface is the same as cc_library.
6 7 8
    # But it handle split GPU/CPU code and link some common library.
    set(cc_srcs)
    set(cu_srcs)
9
    set(hip_srcs)
10
    set(math_common_deps device_context framework_proto enforce)
Z
Zeng Jinle 已提交
11 12 13
    if (WITH_GPU)
        list(APPEND math_common_deps cub)
    endif()
14
    set(multiValueArgs DEPS)
15 16 17 18 19 20 21 22 23
    cmake_parse_arguments(math_library "${options}" "${oneValueArgs}"
            "${multiValueArgs}" ${ARGN})

    if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.cc)
        list(APPEND cc_srcs ${TARGET}.cc)
    endif()
    if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.cu)
        list(APPEND cu_srcs ${TARGET}.cu)
    endif()
24 25 26
    if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.cu.cc)
        list(APPEND cu_srcs ${TARGET}.cu.cc)
    endif()
27 28 29
    if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.hip.cu)
        list(APPEND hip_srcs ${TARGET}.hip.cu)
    endif()
30

31
    list(LENGTH cc_srcs cc_srcs_len)
32 33
    if (WITH_GPU)
        nv_library(${TARGET} SRCS ${cc_srcs} ${cu_srcs} DEPS ${math_library_DEPS} ${math_common_deps})
34 35
    elseif (WITH_AMD_GPU)
        hip_library(${TARGET} SRCS ${cc_srcs} ${hip_srcs} DEPS ${math_library_DEPS} ${math_common_deps})
36
    elseif(${cc_srcs_len} GREATER 0)
37 38 39 40
        cc_library(${TARGET} SRCS ${cc_srcs} DEPS ${math_library_DEPS} ${math_common_deps})
    endif()
endfunction()

41
# please add new math_library in alphabetical order
C
chengduo 已提交
42
math_library(concat_and_split)
43
math_library(context_project DEPS im2col math_function)
44
math_library(cross_entropy)
45
math_library(cos_sim_functor)
Z
Zeng Jinle 已提交
46
math_library(depthwise_conv)
47
math_library(im2col)
X
xuezhong 已提交
48
math_library(sample_prob)
49
math_library(sampler)
D
dzhwinter 已提交
50

W
wopeizl 已提交
51 52
math_library(gru_compute DEPS activation_functions math_function)
math_library(lstm_compute DEPS activation_functions)
D
dzhwinter 已提交
53

54
cc_library(blas SRCS blas.cc DEPS cblas framework_proto device_context)
Y
Yu Yang 已提交
55
math_library(math_function DEPS blas)
56
math_library(maxouting)
57
math_library(pooling)
M
minqiyang 已提交
58
math_library(selected_rows_functor DEPS selected_rows math_function blas)
59 60
math_library(sequence2batch)
math_library(sequence_padding)
T
tensor-tang 已提交
61
math_library(sequence_pooling DEPS math_function jit_kernel_helper)
62
math_library(sequence_scale)
T
tensor-tang 已提交
63
math_library(softmax DEPS math_function jit_kernel_helper)
64
math_library(beam_search DEPS math_function)
65
math_library(fc DEPS blas)
W
wopeizl 已提交
66 67 68

math_library(matrix_bit_code)

69
math_library(unpooling)
70
math_library(vol2col)
N
nhzlx 已提交
71
math_library(prelu)
72
math_library(bert_encoder_functor)
Z
zhaozhehao 已提交
73
math_library(tree2col DEPS math_function)
74
math_library(matrix_inverse)
Q
qijun 已提交
75

76
cc_test(math_function_test SRCS math_function_test.cc DEPS math_function)
77
cc_test(selected_rows_functor_test SRCS selected_rows_functor_test.cc DEPS selected_rows_functor)
78 79
cc_test(im2col_test SRCS im2col_test.cc DEPS im2col)
cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col)
Y
Yiqun Liu 已提交
80
cc_test(sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding)
81
cc_test(sequence_pooling_test SRCS sequence_pooling_test.cc DEPS sequence_pooling)
82
cc_test(beam_search_test SRCS beam_search_test.cc DEPS beam_search)
83
if(WITH_GPU)
84
    nv_test(math_function_gpu_test SRCS math_function_test.cu DEPS math_function)
Y
Yu Yang 已提交
85
    nv_test(selected_rows_functor_gpu_test SRCS selected_rows_functor_test.cu.cc DEPS selected_rows_functor math_function)
86
endif()
C
chengduo 已提交
87
cc_test(concat_test SRCS concat_test.cc DEPS concat_and_split)
T
tensor-tang 已提交
88
cc_test(cpu_vec_test SRCS cpu_vec_test.cc DEPS blas cpu_info)