CMakeLists.txt 4.9 KB
Newer Older
Z
zhangjinchao01 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# Gserver package contains:
#   * Layers
#   * Activations
#   * DataProviders
#   * Evaluators
#   * GradientMachines(NeuralNetwork)
file(GLOB_RECURSE GSERVER_HEADER RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h")
file(GLOB_RECURSE GSERVER_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp")
set(GSERVER_SOURCES
    layers/LstmCompute.cu
    layers/GruCompute.cu
    ${GSERVER_SOURCES})

macro(filter_test VAR_NAME)
    set(tmp)
    foreach(p IN LISTS ${VAR_NAME})
        if(NOT ${p} MATCHES ".*tests/.*")
             set(tmp ${p} ${tmp})
        endif()
    endforeach()
    set(${VAR_NAME} ${tmp})
endmacro()

filter_test(GSERVER_HEADER)
filter_test(GSERVER_SOURCES)
T
tensor-tang 已提交
26 27

if(NOT WITH_MKLDNN)
28 29
    file(GLOB_RECURSE DNN_HEADER RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "MKLDNN*.h")
    file(GLOB_RECURSE DNN_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "MKLDNN*.cpp")
T
tensor-tang 已提交
30 31
    list(REMOVE_ITEM GSERVER_HEADER ${DNN_HEADER})
    list(REMOVE_ITEM GSERVER_SOURCES ${DNN_SOURCES})
32
    message(STATUS "Skip compiling with MKLDNNLayers and MKLDNNActivations")
T
tensor-tang 已提交
33
else()
34
    message(STATUS "Compile with MKLDNNLayers and MKLDNNActivations")
T
tensor-tang 已提交
35 36
endif()

T
tensor-tang 已提交
37 38 39 40 41 42 43 44 45 46
if(NOT WITH_MKLML)
    file(GLOB_RECURSE MKL_HEADER RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "MKLPacked*.h")
    file(GLOB_RECURSE MKL_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "MKLPacked*.cpp")
    list(REMOVE_ITEM GSERVER_HEADER ${MKL_HEADER})
    list(REMOVE_ITEM GSERVER_SOURCES ${MKL_SOURCES})
    message(STATUS "Skip compiling with MKLPackedLayers")
else()
    message(STATUS "Compile with MKLPackedLayers")
endif()

Z
zhangjinchao01 已提交
47 48
if(NOT WITH_GPU)
    list(REMOVE_ITEM GSERVER_HEADER
W
wangyang59 已提交
49
        layers/CudnnConvBaseLayer.h
Z
zhangjinchao01 已提交
50
        layers/CudnnConvLayer.h
W
wangyang59 已提交
51
        layers/CudnnConvTransLayer.h
Z
zhangjinchao01 已提交
52
        layers/CudnnPoolLayer.h
H
hedaoyuan 已提交
53
        layers/CudnnBatchNormLayer.h)
Z
zhangjinchao01 已提交
54 55

    list(REMOVE_ITEM GSERVER_SOURCES
W
wangyang59 已提交
56
        layers/CudnnConvBaseLayer.cpp
Z
zhangjinchao01 已提交
57
        layers/CudnnConvLayer.cpp
W
wangyang59 已提交
58
        layers/CudnnConvTransLayer.cpp
Z
zhangjinchao01 已提交
59
        layers/CudnnPoolLayer.cpp
H
hedaoyuan 已提交
60
        layers/CudnnBatchNormLayer.cpp)
Z
zhangjinchao01 已提交
61 62 63 64 65 66 67 68 69 70 71 72
    compile_cu_as_cpp(layers/LstmCompute.cu)
    compile_cu_as_cpp(layers/GruCompute.cu)
endif()

if(NOT WITH_PYTHON)
    list(REMOVE_ITEM GSERVER_SOURCES
            dataproviders/PyDataProvider.cpp)
    
    list(REMOVE_ITEM GSERVER_HEADER
            dataproviders/PyDataProvider.h)
endif()

73 74 75 76 77 78 79 80 81
if(MOBILE_INFERENCE)
    # Remove evaluators
    list(REMOVE_ITEM GSERVER_SOURCES
         layers/ValidationLayer.cpp
         evaluators/Evaluator.cpp
         evaluators/DetectionMAPEvaluator.cpp
         evaluators/CTCErrorEvaluator.cpp
         evaluators/ChunkEvaluator.cpp)

H
hedaoyuan 已提交
82 83 84 85 86 87 88
    # Remove dataproviders
    list(REMOVE_ITEM GSERVER_SOURCES
         dataproviders/DataProvider.cpp
         dataproviders/MultiDataProvider.cpp
         dataproviders/PyDataProvider2.cpp
         dataproviders/PyDataProvider.cpp)

89 90 91 92 93 94 95 96
    # Remove useless gradientmachines
    list(REMOVE_ITEM GSERVER_SOURCES
         gradientmachines/MultiNetwork.cpp
         gradientmachines/RecurrentGradientMachine.cpp
         gradientmachines/ParallelNeuralNetwork.cpp
         gradientmachines/GradientMachineMode.cpp
         gradientmachines/MultiGradientMachine.cpp)

97
    # Remove layers that used in training
98
    list(REMOVE_ITEM GSERVER_SOURCES
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    	 layers/RecurrentLayerGroup.cpp
         layers/CostLayer.cpp
         layers/MultiBoxLossLayer.cpp
         layers/WarpCTCLayer.cpp
         layers/CTCLayer.cpp
         layers/LinearChainCTC.cpp
         layers/PrintLayer.cpp)
    list(REMOVE_ITEM GSERVER_SOURCES
         layers/OuterProdLayer.cpp
         layers/SumToOneNormLayer.cpp
         layers/ConvShiftLayer.cpp
         layers/InterpolationLayer.cpp
         layers/AgentLayer.cpp
         layers/DotMulOperator.cpp
         layers/GruStepLayer.cpp
         layers/LstmStepLayer.cpp
         layers/ConvexCombinationLayer.cpp
         layers/Conv3DLayer.cpp
         layers/DeConv3DLayer.cpp
         layers/CropLayer.cpp
         layers/CrossEntropyOverBeam.cpp
         layers/DataNormLayer.cpp
         layers/FeatureMapExpandLayer.cpp
         layers/HierarchicalSigmoidLayer.cpp
         layers/MultinomialSampler.cpp
         layers/NCELayer.cpp
         layers/KmaxSeqScoreLayer.cpp
         layers/MDLstmLayer.cpp
         layers/MultiplexLayer.cpp
         layers/PadLayer.cpp
         layers/Pool3DLayer.cpp
         layers/ResizeLayer.cpp
         layers/RotateLayer.cpp
         layers/RowConvLayer.cpp
         layers/RowL2NormLayer.cpp
         layers/SamplingIdLayer.cpp
         layers/ScaleShiftLayer.cpp
         layers/SelectiveFullyConnectedLayer.cpp
         layers/SpatialPyramidPoolLayer.cpp
         layers/BilinearInterpLayer.cpp
         layers/ClipLayer.cpp)
140 141
endif()

Z
zhangjinchao01 已提交
142
if(WITH_GPU)
H
hedaoyuan 已提交
143
    cuda_add_library(paddle_gserver ${GSERVER_SOURCES})
Z
zhangjinchao01 已提交
144 145 146 147 148
else()
    add_library(paddle_gserver STATIC
        ${GSERVER_SOURCES})
endif()

Y
Yu Yang 已提交
149
add_dependencies(paddle_gserver paddle_proto ${external_project_dependencies})
Z
zhangjinchao01 已提交
150 151 152
if(WITH_TESTING)
    add_subdirectory(tests)
endif()