CMakeLists.txt 2.3 KB
Newer Older
1 2
add_subdirectory(detail)

3 4 5 6 7 8
function(math_library TARGET)
    # math_library is a function to create math library. 
    # The interface is the same as cc_library. 
    # But it handle split GPU/CPU code and link some common library.
    set(cc_srcs)
    set(cu_srcs)
L
Luo Tao 已提交
9
    set(math_common_deps device_context framework_proto)
10
    set(multiValueArgs DEPS)
11 12 13 14 15 16 17 18 19 20
    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()

21
    list(LENGTH cc_srcs cc_srcs_len)
22 23
    if (WITH_GPU)
        nv_library(${TARGET} SRCS ${cc_srcs} ${cu_srcs} DEPS ${math_library_DEPS} ${math_common_deps})
24
    elseif(${cc_srcs_len} GREATER 0)
25 26 27 28
        cc_library(${TARGET} SRCS ${cc_srcs} DEPS ${math_library_DEPS} ${math_common_deps})
    endif()
endfunction()

29 30 31
# please add new math_library in alphabetical order
math_library(concat)
math_library(context_project DEPS im2col math_function)
32
math_library(cross_entropy)
33 34 35 36 37
math_library(cos_sim_functor)
math_library(depthwise_conv)
math_library(gru_compute DEPS activation_functions math_function)
math_library(im2col)
math_library(lstm_compute DEPS activation_functions)
L
Luo Tao 已提交
38
math_library(math_function DEPS cblas)
39
math_library(maxouting)
40
math_library(pooling)
41
math_library(selected_rows_functor DEPS selected_rows math_function)
42 43
math_library(sequence2batch)
math_library(sequence_padding)
44
math_library(sequence_pooling DEPS math_function)
45
math_library(sequence_scale)
46
math_library(softmax)
47
math_library(unpooling)
48
math_library(vol2col)
Q
qijun 已提交
49

50
cc_test(math_function_test SRCS math_function_test.cc)
51
cc_test(selected_rows_functor_test SRCS selected_rows_functor_test.cc DEPS selected_rows_functor)
52 53
cc_test(im2col_test SRCS im2col_test.cc DEPS im2col)
cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col)
Y
Yiqun Liu 已提交
54
cc_test(sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding)
55 56 57 58
if(WITH_GPU)
    nv_test(math_function_gpu_test SRCS math_function_test.cu)
    nv_test(selected_rows_functor_gpu_test SRCS selected_rows_functor_test.cu DEPS selected_rows_functor)
endif()
59
cc_test(concat_test SRCS concat_test.cc DEPS concat)