Skip to content

Commit ee2da53

Browse files
committed
Merge branch 'develop' of https://github.com/baidu/Paddle into buffer
2 parents df9be2d + cb0a1e2 commit ee2da53

File tree

146 files changed

+1920
-873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+1920
-873
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ build/
99
.pydevproject
1010
Makefile
1111
.test_env/
12+
third_party/
1213

1314
*~
1415
bazel-*
16+
third_party/

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sha: c25201a00e6b0514370501050cf2a8538ac12270
33
hooks:
44
- id: remove-crlf
5-
files: (?!.*warp-ctc)^.*$
5+
files: (?!.*third_party)^.*$
66
- repo: https://github.com/reyoung/mirrors-yapf.git
77
sha: v0.13.2
88
hooks:
@@ -15,7 +15,7 @@
1515
- id: check-merge-conflict
1616
- id: check-symlinks
1717
- id: detect-private-key
18-
files: (?!.*warp-ctc)^.*$
18+
files: (?!.*third_party)^.*$
1919
- id: end-of-file-fixer
2020
- repo: https://github.com/PaddlePaddle/clang-format-pre-commit-hook.git
2121
sha: 28c0ea8a67a3e2dbbf4822ef44e85b63a0080a29

.travis.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,17 @@ addons:
2121
packages:
2222
- gcc-4.8
2323
- g++-4.8
24-
- wget
2524
- git
2625
- build-essential
2726
- libatlas-base-dev
2827
- python
2928
- python-pip
3029
- python2.7-dev
31-
- m4
3230
- python-numpy
3331
- python-wheel
34-
- libgoogle-glog-dev
35-
- libgflags-dev
36-
- libgtest-dev
3732
- curl
38-
- lcov
39-
- graphviz
4033
- swig
34+
- graphviz
4135
- clang-format-3.8
4236
- automake
4337
- libtool
@@ -53,10 +47,9 @@ before_install:
5347
fi
5448
fi
5549
fi
56-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi
5750
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi
5851
- if [[ "$JOB" == "PRE_COMMIT" ]]; then sudo ln -s /usr/bin/clang-format-3.8 /usr/bin/clang-format; fi
59-
- pip install wheel protobuf sphinx recommonmark virtualenv numpy sphinx_rtd_theme pre-commit requests==2.9.2 LinkChecker
52+
- pip install numpy wheel protobuf sphinx recommonmark sphinx_rtd_theme virtualenv pre-commit requests==2.9.2 LinkChecker
6053
script:
6154
- paddle/scripts/travis/main.sh
6255
notifications:

CMakeLists.txt

Lines changed: 79 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,99 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License
14+
15+
cmake_minimum_required(VERSION 3.0)
216

317
project(paddle CXX C)
418

519
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
620
set(PROJ_ROOT ${CMAKE_SOURCE_DIR})
7-
include(package)
8-
find_package(SWIG 2.0)
9-
find_package(CUDA QUIET)
10-
find_package(Protobuf REQUIRED)
11-
12-
# Check protobuf library version.
13-
execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version
14-
OUTPUT_VARIABLE PROTOBUF_VERSION)
15-
string(REPLACE "libprotoc " "" PROTOBUF_VERSION ${PROTOBUF_VERSION})
16-
17-
set(PROTOBUF_3 OFF)
18-
if (${PROTOBUF_VERSION} VERSION_GREATER "3.0.0" OR ${PROTOBUF_VERSION} VERSION_EQUAL "3.0.0")
19-
set(PROTOBUF_3 ON)
20-
endif()
2121

22-
find_package(PythonLibs 2.7 REQUIRED)
23-
find_package(PythonInterp 2.7 REQUIRED)
24-
find_package(ZLIB REQUIRED)
25-
find_package(NumPy REQUIRED)
26-
find_package(Threads REQUIRED)
27-
find_package(AVX QUIET)
28-
find_package(Glog REQUIRED)
29-
find_package(Gflags REQUIRED)
30-
find_package(GTest)
3122
find_package(Sphinx)
32-
find_package(Doxygen)
33-
include(cblas)
34-
find_program(M4_EXECUTABLE m4)
35-
###################### Configurations ###########################
36-
option(WITH_DSO "Compile PaddlePaddle with dynamic linked libraries" ON)
37-
option(WITH_GPU "Compile PaddlePaddle with gpu" ${CUDA_FOUND})
38-
option(WITH_DOUBLE "Compile PaddlePaddle with double precision, otherwise use single precision" OFF)
39-
option(WITH_AVX "Compile PaddlePaddle with avx intrinsics" ${AVX_FOUND})
40-
option(WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON)
41-
option(WITH_STYLE_CHECK "Style Check for PaddlePaddle" ${PYTHONINTERP_FOUND})
42-
option(WITH_RDMA "Compile PaddlePaddle with rdma support" OFF)
43-
option(WITH_TIMER "Compile PaddlePaddle use timer" OFF)
44-
option(WITH_PROFILER "Compile PaddlePaddle use gpu profiler" OFF)
45-
option(WITH_TESTING "Compile and run unittest for PaddlePaddle" ${GTEST_FOUND})
46-
option(WITH_DOC "Compile PaddlePaddle with documentation" OFF)
47-
option(WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" ${SWIG_FOUND})
48-
option(ON_TRAVIS "Running test on travis-ci or not." OFF)
49-
option(ON_COVERALLS "Generating code coverage data on coveralls or not." OFF)
50-
option(COVERALLS_UPLOAD "Uploading the generated coveralls json." ON)
51-
52-
53-
include(cpplint)
54-
include(ccache)
55-
if(WITH_RDMA)
56-
include(rdma)
57-
endif()
58-
include(util)
59-
include(flags)
60-
include(cudnn)
61-
include(FindPythonModule)
62-
include(check_packages)
63-
include(swig)
64-
include(coveralls)
65-
66-
# Set PaddlePaddle version to Git tag name or Git commit ID.
23+
find_package(CUDA QUIET)
6724
find_package(Git REQUIRED)
68-
# version.cmake will get the current PADDLE_VERSION
69-
include(version)
70-
add_definitions(-DPADDLE_VERSION=${PADDLE_VERSION})
71-
72-
if(NOT WITH_GPU)
73-
add_definitions(-DPADDLE_ONLY_CPU)
74-
add_definitions(-DHPPL_STUB_FUNC)
75-
76-
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu)
77-
else()
78-
if(${CUDA_VERSION_MAJOR} VERSION_LESS 7)
79-
message(FATAL_ERROR "Paddle need CUDA >= 7.0 to compile")
80-
endif()
81-
82-
if(NOT CUDNN_FOUND)
83-
message(FATAL_ERROR "Paddle need cudnn to compile")
84-
endif()
85-
86-
if(WITH_AVX)
87-
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${AVX_FLAG}")
88-
else(WITH_AVX)
89-
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${SSE3_FLAG}")
90-
endif(WITH_AVX)
91-
92-
# Include cuda and cudnn
93-
include_directories(${CUDNN_INCLUDE_DIR})
94-
include_directories(${CUDA_TOOLKIT_INCLUDE})
95-
endif(NOT WITH_GPU)
96-
97-
if(WITH_DSO)
98-
add_definitions(-DPADDLE_USE_DSO)
99-
endif(WITH_DSO)
100-
101-
if(WITH_DOUBLE)
102-
add_definitions(-DPADDLE_TYPE_DOUBLE)
103-
set(ACCURACY double)
104-
else(WITH_DOUBLE)
105-
set(ACCURACY float)
106-
endif(WITH_DOUBLE)
107-
108-
if(NOT WITH_TIMER)
109-
add_definitions(-DPADDLE_DISABLE_TIMER)
110-
endif(NOT WITH_TIMER)
111-
112-
if(NOT WITH_PROFILER)
113-
add_definitions(-DPADDLE_DISABLE_PROFILER)
114-
endif(NOT WITH_PROFILER)
115-
116-
if(WITH_AVX)
117-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AVX_FLAG}")
118-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX_FLAG}")
119-
else(WITH_AVX)
120-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SSE3_FLAG}")
121-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE3_FLAG}")
122-
endif(WITH_AVX)
123-
124-
if(WITH_PYTHON)
125-
include_directories(${PYTHON_INCLUDE_DIR})
126-
include_directories(${PYTHON_NUMPY_INCLUDE_DIR})
127-
else(WITH_PYTHON)
128-
add_definitions(-DPADDLE_NO_PYTHON)
129-
endif(WITH_PYTHON)
130-
131-
if(WITH_RDMA)
132-
include_directories("${RDMA_INC_DIR}")
133-
else(WITH_RDMA)
134-
add_definitions(-DPADDLE_DISABLE_RDMA)
135-
endif(WITH_RDMA)
136-
137-
# glog
138-
include_directories(${LIBGLOG_INCLUDE_DIR})
139-
140-
#gflags
141-
add_definitions(-DGFLAGS_NS=${GFLAGS_NAMESPACE})
142-
include_directories(${GFLAGS_INCLUDE_DIRS})
25+
find_package(Threads REQUIRED)
14326

144-
if(WITH_TESTING)
145-
enable_testing()
146-
include_directories(${GTEST_INCLUDE_DIRS})
27+
include(system)
28+
include(simd)
29+
30+
################################ Configurations #######################################
31+
option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND})
32+
option(WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND})
33+
option(WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" OFF)
34+
option(WITH_TESTING "Compile PaddlePaddle with unit testing" ON)
35+
option(WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON)
36+
option(WITH_STYLE_CHECK "Compile PaddlePaddle with style check" ON)
37+
option(WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON)
38+
option(WITH_DOUBLE "Compile PaddlePaddle with double precision" OFF)
39+
option(WITH_RDMA "Compile PaddlePaddle with RDMA support" OFF)
40+
option(WITH_TIMER "Compile PaddlePaddle with stats timer" OFF)
41+
option(WITH_PROFILER "Compile PaddlePaddle with GPU profiler" OFF)
42+
option(WITH_DOC "Compile PaddlePaddle with documentation" OFF)
43+
option(ON_COVERALLS "Compile PaddlePaddle with code coverage" OFF)
44+
option(COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF)
45+
option(ON_TRAVIS "Exclude special unit test on Travis CI" OFF)
46+
47+
# CMAKE_BUILD_TYPE
48+
if(NOT CMAKE_BUILD_TYPE)
49+
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
50+
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
51+
FORCE)
14752
endif()
14853

149-
include_directories("${CBLAS_INC_DIR}")
54+
set(THIRD_PARTY_PATH "${PROJ_ROOT}/third_party" CACHE STRING
55+
"A path setting third party libraries download & build directories.")
56+
########################################################################################
57+
58+
include(external/zlib) # download, build, install zlib
59+
include(external/gflags) # download, build, install gflags
60+
include(external/glog) # download, build, install glog
61+
include(external/gtest) # download, build, install gtest
62+
include(external/protobuf) # download, build, install protobuf
63+
include(external/python) # download, build, install python
64+
include(external/openblas) # download, build, install openblas
65+
include(external/swig) # download, build, install swig
66+
include(external/warpctc) # download, build, install warpctc
67+
68+
include(package) # set paddle packages
69+
include(cpplint) # set paddle c++ style
70+
include(ccache) # set ccache for compilation
71+
include(util) # set unittest and link libs
72+
include(rdma) # set rdma libraries
73+
include(flags) # set paddle compile flags
74+
include(cudnn) # set cudnn libraries
75+
include(version) # set PADDLE_VERSION
76+
include(coveralls) # set code coverage
77+
78+
include(configure) # add paddle env configuration
79+
15080
include_directories("${PROJ_ROOT}")
15181
include_directories("${PROJ_ROOT}/paddle/cuda/include")
152-
include_directories(${PROTOBUF_INCLUDE_DIRS})
15382
include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto")
154-
if(EXISTS "${PROJ_ROOT}/paddle/internals/CMakeLists.txt")
155-
set(PADDLE_WITH_INTERNAL ON)
156-
include(paddle/internals/CMakeLists.txt)
157-
else()
158-
set(PADDLE_WITH_INTERNAL OFF)
159-
set(INTERNAL_PROTO_PATH "")
160-
endif()
83+
84+
set(EXTERNAL_LIBS
85+
# have not include gtest here.
86+
${GFLAGS_LIBRARIES}
87+
${GLOG_LIBRARIES}
88+
${CBLAS_LIBRARIES}
89+
${PROTOBUF_LIBRARY}
90+
${ZLIB_LIBRARIES}
91+
)
92+
16193
add_subdirectory(proto)
16294
add_subdirectory(paddle)
16395
add_subdirectory(python)
96+
16497
if(WITH_DOC)
16598
add_subdirectory(doc)
16699
endif()

cmake/cblas.cmake

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# system paths.
1414
#
1515

16+
set(CBLAS_FOUND OFF)
1617

1718
## Find MKL First.
1819
set(MKL_ROOT $ENV{MKL_ROOT} CACHE PATH "Folder contains MKL")
@@ -35,11 +36,12 @@ find_library(MKL_INTEL_LP64 NAMES mkl_intel_lp64 PATHS
3536
if(MKL_INCLUDE_DIR AND MKL_CORE_LIB AND MKL_SEQUENTIAL_LIB AND MKL_INTEL_LP64)
3637
set(CBLAS_PROVIDER MKL)
3738
set(CBLAS_INC_DIR ${MKL_INCLUDE_DIR})
38-
set(CBLAS_LIBS ${MKL_INTEL_LP64}
39+
set(CBLAS_LIBRARIES ${MKL_INTEL_LP64}
3940
${MKL_SEQUENTIAL_LIB}
4041
${MKL_CORE_LIB})
4142
add_definitions(-DPADDLE_USE_MKL)
42-
message(STATUS "Found MKL (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBS})")
43+
message(STATUS "Found MKL (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
44+
set(CBLAS_FOUND ON)
4345
return() # return file.
4446
endif()
4547

@@ -68,9 +70,10 @@ find_library(ATLAS_LIB NAMES lapack_atlas liblapack_atlas.so.3
6870
if(ATLAS_INC_DIR AND ATLAS_CBLAS_LIB AND ATLAS_LIB)
6971
set(CBLAS_PROVIDER ATLAS)
7072
set(CBLAS_INC_DIR ${ATLAS_INC_DIR} ${ATLAS_CLAPACK_INC_DIR})
71-
set(CBLAS_LIBS ${ATLAS_LIB} ${ATLAS_CBLAS_LIB})
73+
set(CBLAS_LIBRARIES ${ATLAS_LIB} ${ATLAS_CBLAS_LIB})
7274
add_definitions(-DPADDLE_USE_ATLAS)
73-
message(STATUS "Found Atlas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBS})")
75+
message(STATUS "Found Atlas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
76+
set(CBLAS_FOUND ON)
7477
return()
7578
endif()
7679

@@ -98,8 +101,9 @@ find_library(OPENBLAS_LIB NAMES openblas
98101
if(OPENBLAS_INC_DIR AND OPENBLAS_LIB)
99102
set(CBLAS_PROVIDER OPENBLAS)
100103
set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR})
101-
set(CBLAS_LIBS ${OPENBLAS_LIB})
102-
message(STATUS "Found OpenBlas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBS})")
104+
set(CBLAS_LIBRARIES ${OPENBLAS_LIB})
105+
message(STATUS "Found OpenBlas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
106+
set(CBLAS_FOUND ON)
103107
return()
104108
endif()
105109

@@ -130,9 +134,7 @@ find_library(REFERENCE_CBLAS_LIBRARY NAMES cblas PATHS
130134
if (REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
131135
set(CBLAS_PROVIDER REFERENCE)
132136
set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR})
133-
set(CBLAS_LIBS ${REFERENCE_CBLAS_LIBRARY})
134-
return()
137+
set(CBLAS_LIBRARIES ${REFERENCE_CBLAS_LIBRARY})
138+
message(STATUS "Found reference-cblas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBS})")
139+
set(CBLAS_FOUND ON)
135140
endif()
136-
137-
message(FATAL_ERROR "CBlas must be set. Paddle support MKL, ATLAS, OpenBlas, reference-cblas."
138-
" Try set MKL_ROOT, ATLAS_ROOT, OPENBLAS_ROOT or REFERENCE_CBLAS_ROOT.")

0 commit comments

Comments
 (0)