CMakeLists.txt 3.5 KB
Newer Older
D
dzhwinter 已提交
1
if (NOT WIN32)
C
chengduo 已提交
2
    add_subdirectory(detail)
D
dzhwinter 已提交
3
endif(NOT WIN32)
4

5
function(math_library TARGET)
M
minqiyang 已提交
6 7
    # math_library is a function to create math library.
    # The interface is the same as cc_library.
8 9 10
    # But it handle split GPU/CPU code and link some common library.
    set(cc_srcs)
    set(cu_srcs)
11
    set(hip_srcs)
L
Luo Tao 已提交
12
    set(math_common_deps device_context framework_proto)
13
    set(multiValueArgs DEPS)
14 15 16 17 18 19 20 21 22
    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()
23 24 25
    if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.hip.cu)
        list(APPEND hip_srcs ${TARGET}.hip.cu)
    endif()
26

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

37
# please add new math_library in alphabetical order
C
chengduo 已提交
38
math_library(concat_and_split)
39
math_library(context_project DEPS im2col math_function)
40
math_library(cross_entropy)
41 42 43
math_library(cos_sim_functor)
math_library(depthwise_conv)
math_library(im2col)
44
math_library(sampler)
D
dzhwinter 已提交
45 46

if (NOT WIN32) # windows do not support avx functions yet.
C
chengduo 已提交
47 48
    math_library(gru_compute DEPS activation_functions math_function)
    math_library(lstm_compute DEPS activation_functions)
D
dzhwinter 已提交
49 50
endif (NOT WIN32)

51
cc_library(blas SRCS blas.cc DEPS cblas framework_proto device_context)
Y
Yu Yang 已提交
52
math_library(math_function DEPS blas)
53
math_library(maxouting)
54
math_library(pooling)
M
minqiyang 已提交
55
math_library(selected_rows_functor DEPS selected_rows math_function blas)
56 57
math_library(sequence2batch)
math_library(sequence_padding)
58
math_library(sequence_pooling DEPS math_function)
59
math_library(sequence_scale)
60
math_library(softmax DEPS math_function)
D
dzhwinter 已提交
61
if (NOT WIN32)
C
chengduo 已提交
62
    math_library(matrix_bit_code)
D
dzhwinter 已提交
63
endif (NOT WIN32)
64
math_library(unpooling)
65
math_library(vol2col)
Q
qijun 已提交
66

67
cc_test(math_function_test SRCS math_function_test.cc DEPS math_function)
68
cc_test(selected_rows_functor_test SRCS selected_rows_functor_test.cc DEPS selected_rows_functor)
69 70
cc_test(im2col_test SRCS im2col_test.cc DEPS im2col)
cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col)
Y
Yiqun Liu 已提交
71
cc_test(sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding)
72
cc_test(sequence_pooling_test SRCS sequence_pooling_test.cc DEPS sequence_pooling)
73
if(WITH_GPU)
74
    nv_test(math_function_gpu_test SRCS math_function_test.cu DEPS math_function)
Y
Yu Yang 已提交
75
    nv_test(selected_rows_functor_gpu_test SRCS selected_rows_functor_test.cu.cc DEPS selected_rows_functor math_function)
76
endif()
C
chengduo 已提交
77
cc_test(concat_test SRCS concat_test.cc DEPS concat_and_split)
T
tensor-tang 已提交
78
cc_test(cpu_vec_test SRCS cpu_vec_test.cc DEPS blas cpu_info)
P
peizhilin 已提交
79
if (NOT WIN32)
80
    set(JIT_KERNEL_SRCS jit_kernel.cc jit_kernel_blas.cc jit_kernel_exp.cc jit_kernel_rnn.cc jit_kernel_crf_decode.cc jit_kernel_layer_norm.cc)
81 82 83 84 85
    set(JIT_KERNEL_DEPS cpu_info cblas gflags enforce)
    if(WITH_XBYAK)
        list(APPEND JIT_KERNEL_SRCS jit_gen.cc jit_code.cc)
        list(APPEND JIT_KERNEL_DEPS xbyak)
    endif()
P
peizhilin 已提交
86 87
    cc_library(jit_kernel SRCS ${JIT_KERNEL_SRCS} DEPS ${JIT_KERNEL_DEPS})
    cc_test(jit_kernel_test SRCS jit_kernel_test.cc DEPS jit_kernel)
D
dzhwinter 已提交
88
endif (NOT WIN32)