CMakeLists.txt 4.6 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
    if (WITH_GPU)
12 13 14 15 16
        if (${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0)	
            list(APPEND math_common_deps cub)
	else()
            list(APPEND math_common_deps)
	endif()
Z
Zeng Jinle 已提交
17
    endif()
18
    set(multiValueArgs DEPS)
19 20 21 22 23 24 25 26 27
    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()
28 29 30
    if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.cu.cc)
        list(APPEND cu_srcs ${TARGET}.cu.cc)
    endif()
31

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

P
pangyoki 已提交
42 43 44 45
if (WITH_ASCEND_CL)
  cc_library(beam_search_npu SRCS beam_search_npu.cc DEPS npu_op_runner)
endif()

46
# please add new math_library in alphabetical order
47 48 49
if (WITH_ASCEND_CL)
math_library(concat_and_split DEPS npu_op_runner)
else()
C
chengduo 已提交
50
math_library(concat_and_split)
51
endif()
52
math_library(context_project DEPS im2col math_function)
53
math_library(cross_entropy)
54
math_library(cos_sim_functor)
Z
Zeng Jinle 已提交
55
math_library(depthwise_conv)
56
math_library(im2col)
X
xuezhong 已提交
57
math_library(sample_prob)
58
math_library(sampler DEPS generator)
D
dzhwinter 已提交
59

W
wopeizl 已提交
60 61
math_library(gru_compute DEPS activation_functions math_function)
math_library(lstm_compute DEPS activation_functions)
D
dzhwinter 已提交
62

63
cc_library(blas SRCS blas.cc DEPS cblas framework_proto device_context)
64
math_library(math_function DEPS blas dense_tensor tensor)
65
math_library(maxouting)
66
math_library(pooling)
L
lidanqing 已提交
67 68

if(WITH_MKLDNN)
69
    math_library(selected_rows_functor DEPS selected_rows_utils math_function blas mkldnn_axpy_handler)
L
lidanqing 已提交
70
else()
71
    math_library(selected_rows_functor DEPS selected_rows_utils math_function blas)
L
lidanqing 已提交
72 73
endif()

74 75
math_library(sequence2batch)
math_library(sequence_padding)
T
tensor-tang 已提交
76
math_library(sequence_pooling DEPS math_function jit_kernel_helper)
77
math_library(sequence_scale)
T
tensor-tang 已提交
78
math_library(softmax DEPS math_function jit_kernel_helper)
P
pangyoki 已提交
79 80 81 82 83
if (WITH_ASCEND_CL)
    math_library(beam_search DEPS math_function beam_search_npu)
else()
    math_library(beam_search DEPS math_function)
endif()
84
math_library(fc DEPS blas)
85
math_library(lapack_function DEPS dynload_lapack)
W
wopeizl 已提交
86 87 88

math_library(matrix_bit_code)

89
math_library(unpooling)
90
math_library(vol2col)
N
nhzlx 已提交
91
math_library(prelu)
92
math_library(bert_encoder_functor)
Z
zhaozhehao 已提交
93
math_library(tree2col DEPS math_function)
94
math_library(matrix_inverse)
95
math_library(segment_pooling)
W
Weilong Wu 已提交
96
math_library(matrix_solve)
Q
qijun 已提交
97

98
cc_test(math_function_test SRCS math_function_test.cc DEPS math_function)
99
cc_test(selected_rows_functor_test SRCS selected_rows_functor_test.cc DEPS selected_rows_functor)
100 101
cc_test(im2col_test SRCS im2col_test.cc DEPS im2col)
cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col)
Y
Yiqun Liu 已提交
102
cc_test(sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding)
103
cc_test(sequence_pooling_test SRCS sequence_pooling_test.cc DEPS sequence_pooling)
104
cc_test(beam_search_test SRCS beam_search_test.cc DEPS beam_search)
105
if(WITH_GPU)
106
    nv_test(math_function_gpu_test SRCS math_function_test.cu DEPS math_function)
Y
Yu Yang 已提交
107
    nv_test(selected_rows_functor_gpu_test SRCS selected_rows_functor_test.cu.cc DEPS selected_rows_functor math_function)
108
endif()
109 110 111 112
if(WITH_ROCM)
    hip_test(math_function_gpu_test SRCS math_function_test.cu DEPS math_function tensor)
    hip_test(selected_rows_functor_gpu_test SRCS selected_rows_functor_test.cu.cc DEPS selected_rows_functor math_function)
endif()
C
chengduo 已提交
113
cc_test(concat_test SRCS concat_test.cc DEPS concat_and_split)
Z
zhangkaihuo 已提交
114 115 116 117 118 119 120 121 122

if(WITH_GPU AND (NOT WITH_ROCM))
#currenty not yet support ROCM 
#the generic conversion APIs of dense and sparse are only supported after cuda11.2
    if((NOT ${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 11.2)) 
        cc_test(cusparse_conversion_api_test SRCS cusparse_conversion_api_test.cc DEPS tensor)
    endif()
endif()

T
tensor-tang 已提交
123
cc_test(cpu_vec_test SRCS cpu_vec_test.cc DEPS blas cpu_info)
124 125
if(WITH_TESTING AND TEST im2col_test)
    set_tests_properties(im2col_test PROPERTIES TIMEOUT 120)
Y
YUNSHEN XIE 已提交
126
endif()