1313# limitations under the License
1414
1515cmake_minimum_required (VERSION 3.0)
16-
1716set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR} /cmake" )
18- set (PROJ_ROOT ${CMAKE_CURRENT_SOURCE_DIR} )
19- set (PROJ_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR} )
17+ set (PADDLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
18+ set (PADDLE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
2019
2120include (system )
2221
@@ -37,6 +36,8 @@ include(simd)
3736################################ Configurations #######################################
3837option (WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND} )
3938option (WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND} )
39+ option (WITH_MKLDNN "Compile PaddlePaddle with mkl-dnn support." ${AVX_FOUND} )
40+ option (WITH_MKLML "Compile PaddlePaddle with mklml package." ${AVX_FOUND} )
4041option (WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON )
4142option (WITH_TESTING "Compile PaddlePaddle with unit testing" ON )
4243option (WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON )
@@ -54,6 +55,7 @@ option(WITH_C_API "Compile PaddlePaddle with C-API(Prediction)" OFF)
5455option (WITH_GOLANG "Compile PaddlePaddle with GOLANG" OFF )
5556option (GLIDE_INSTALL "Download and install go dependencies " ON )
5657option (USE_NNPACK "Compile PaddlePaddle with NNPACK library" OFF )
58+ option (USE_EIGEN_FOR_BLAS "Use matrix multiplication in Eigen" OFF )
5759
5860# CMAKE_BUILD_TYPE
5961if (NOT CMAKE_BUILD_TYPE )
@@ -75,6 +77,10 @@ if(ANDROID)
7577 "Disable PYTHON when cross-compiling for Android" FORCE)
7678 set (WITH_RDMA OFF CACHE STRING
7779 "Disable RDMA when cross-compiling for Android" FORCE)
80+ set (WITH_MKLDNN OFF CACHE STRING
81+ "Disable MKLDNN when cross-compiling for Android" FORCE)
82+ set (WITH_MKLML OFF CACHE STRING
83+ "Disable MKLML package when cross-compiling for Android" FORCE)
7884endif (ANDROID)
7985
8086set (THIRD_PARTY_PATH "${CMAKE_BINARY_DIR} /third_party" CACHE STRING
@@ -88,13 +94,15 @@ endif()
8894
8995########################################################################################
9096
97+ include (external/mklml) # download mklml package
9198include (external/zlib) # download, build, install zlib
9299include (external/gflags) # download, build, install gflags
93100include (external/glog) # download, build, install glog
94101include (external/gtest) # download, build, install gtest
95102include (external/protobuf) # download, build, install protobuf
96103include (external/python) # download, build, install python
97104include (external/openblas) # download, build, install openblas
105+ include (external/mkldnn) # download, build, install mkldnn
98106include (external/swig) # download, build, install swig
99107include (external/warpctc) # download, build, install warpctc
100108include (external/any) # download libn::any
@@ -114,8 +122,8 @@ include(version) # set PADDLE_VERSION
114122include (coveralls) # set code coverage
115123
116124
117- include_directories ("${PROJ_ROOT } " )
118- include_directories ("${PROJ_ROOT } /paddle/cuda/include" )
125+ include_directories ("${PADDLE_SOURCE_DIR } " )
126+ include_directories ("${PADDLE_SOURCE_DIR } /paddle/cuda/include" )
119127include_directories ("${CMAKE_CURRENT_BINARY_DIR} /proto" )
120128include_directories ("${CMAKE_CURRENT_BINARY_DIR} /go/pserver/client/c" )
121129include_directories (${Boost_INCLUDE_DIRS} )
@@ -130,14 +138,19 @@ set(EXTERNAL_LIBS
130138)
131139
132140if (WITH_GPU)
133- list (APPEND EXTERNAL_LIB ${CUDA_LIBRARIES} ${CUDA_rt_LIBRARY} )
141+ list (APPEND EXTERNAL_LIBS ${CUDA_LIBRARIES} ${CUDA_rt_LIBRARY} )
134142 if (NOT WITH_DSO)
135- list (APPEND EXTERNAL_LIB ${CUDNN_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY} )
143+ list (APPEND EXTERNAL_LIBS ${CUDNN_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY} )
136144 endif (NOT WITH_DSO)
137145endif (WITH_GPU)
138146
147+ if (WITH_MKLDNN)
148+ list (APPEND EXTERNAL_LIBS ${MKLDNN_LIB} ${MKLDNN_IOMP_LIB} )
149+ endif ()
150+
139151if (USE_NNPACK)
140- list (APPEND EXTERNAL_LIBS ${NNPACK_LIB} ${PTHREADPOOL_LIB} "rt" )
152+ include (external/nnpack)
153+ list (APPEND EXTERNAL_LIBS ${NNPACK_LIBS} )
141154endif (USE_NNPACK)
142155
143156add_subdirectory (proto)
@@ -152,10 +165,12 @@ if(WITH_GOLANG)
152165 add_subdirectory (go)
153166endif (WITH_GOLANG)
154167
168+ set (PADDLE_PYTHON_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR} /python/build" )
155169add_subdirectory (paddle)
156170if (WITH_PYTHON)
157171 add_subdirectory (python)
158172endif ()
173+
159174if (WITH_DOC)
160175 add_subdirectory (doc )
161176endif ()
0 commit comments