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

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
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)
    set(math_common_deps device_context framework_proto)
    set(multiValueArgs SRCS DEPS)
    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()

    if (WITH_GPU)
        nv_library(${TARGET} SRCS ${cc_srcs} ${cu_srcs} DEPS ${math_library_DEPS} ${math_common_deps})
    else()
        cc_library(${TARGET} SRCS ${cc_srcs} DEPS ${math_library_DEPS} ${math_common_deps})
    endif()
endfunction()

math_library(math_function DEPS cblas)
math_library(im2col)
math_library(selected_rows_functor DEPS selected_rows)
math_library(softmax)
math_library(cross_entropy)
math_library(pooling)
math_library(sequence_pooling)
math_library(vol2col)
math_library(context_project)
math_library(sequence2batch)
math_library(sequence_padding)
math_library(sequence_scale)
math_library(maxouting)
math_library(unpooling)
math_library(cos_sim_functor)
math_library(lstm_compute DEPS activation_functions)
math_library(gru_compute DEPS activation_functions)
Q
qijun 已提交
45
if(WITH_GPU)
X
xzl 已提交
46
    nv_library(depthwise_conv SRCS depthwise_conv.cu DEPS device_context)
Q
qijun 已提交
47
endif()
Q
qijun 已提交
48

49
cc_test(math_function_test SRCS math_function_test.cc)
50
cc_test(selected_rows_functor_test SRCS selected_rows_functor_test.cc DEPS selected_rows_functor)
51 52
cc_test(im2col_test SRCS im2col_test.cc DEPS im2col)
cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col)
Y
Yiqun Liu 已提交
53
cc_test(sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding)
54 55 56 57
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()