CMakeLists.txt 2.0 KB
Newer Older
Z
zhangjinchao01 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# common package contains:
#   * the utilities:
#       * Thread Libs
#       * Memory Manage libs
#       * CommandLine Parser
#       * Logging
#       * Timer/Stats
#   * the math libraries:
#       * Matrix/Vector
#   * the parameter optimizers.
#   * the parameter updater functions.
#
# TODO(yuyang18): separate libs.
#
file(GLOB MATH_HEADERS . *.h)
file(GLOB MATH_SOURCES . *.cpp)
T
tensor-tang 已提交
17 18

if(NOT WITH_MKLDNN)
T
tensor-tang 已提交
19 20 21 22
    set(DNN_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/MKLDNNMatrix.h")
    set(DNN_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/MKLDNNMatrix.cpp")
    list(REMOVE_ITEM MATH_HEADERS "${DNN_HEADER}")
    list(REMOVE_ITEM MATH_SOURCES "${DNN_SOURCE}")
T
tensor-tang 已提交
23 24 25 26 27
    message(STATUS "Skip compiling with MKLDNNMatrix")
else()
    message(STATUS "Compile with MKLDNNMatrix")
endif()

28 29 30 31 32 33 34 35 36 37 38 39 40
if(MOBILE_INFERENCE)
    list(REMOVE_ITEM MATH_SOURCES
         ${CMAKE_CURRENT_SOURCE_DIR}/SIMDFunctions.cpp)
    # Remove sparse
    list(REMOVE_ITEM MATH_HEADERS
         ${CMAKE_CURRENT_SOURCE_DIR}/CpuSparseMatrix.h
         ${CMAKE_CURRENT_SOURCE_DIR}/SparseMatrix.h
         ${CMAKE_CURRENT_SOURCE_DIR}/SparseRowMatrix.h)
    list(REMOVE_ITEM MATH_SOURCES
         ${CMAKE_CURRENT_SOURCE_DIR}/CpuSparseMatrix.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/SparseMatrix.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/SparseRowMatrix.cpp)
endif()
Z
zhangjinchao01 已提交
41
set(MATH_SOURCES
42 43
    "${PADDLE_SOURCE_DIR}/paddle/math/BaseMatrix.cu"
    "${PADDLE_SOURCE_DIR}/paddle/math/TrainingAlgorithmOp.cu"
Z
zhangjinchao01 已提交
44 45 46
    ${MATH_SOURCES})
if(NOT WITH_GPU)
    # then compile BaseMatrix.cu as c++ file
47 48
    compile_cu_as_cpp("${PADDLE_SOURCE_DIR}/paddle/math/BaseMatrix.cu")
    compile_cu_as_cpp("${PADDLE_SOURCE_DIR}/paddle/math/TrainingAlgorithmOp.cu")
Z
zhangjinchao01 已提交
49 50 51
    add_library(paddle_math STATIC
        ${MATH_SOURCES})
else()
H
hedaoyuan 已提交
52
    cuda_add_library(paddle_math ${MATH_SOURCES})
Z
zhangjinchao01 已提交
53 54 55 56 57 58 59
endif()



add_style_check_target(paddle_math ${MATH_SOURCES})
add_style_check_target(paddle_math ${MATH_HEADERS})

Y
Yu Yang 已提交
60
add_dependencies(paddle_math paddle_proto ${external_project_dependencies})  # depends
Z
zhangjinchao01 已提交
61 62 63
if(WITH_TESTING)
    add_subdirectory(tests)
endif()