Skip to content

Commit d539e78

Browse files
committed
Merge commit '12b619343b0e8e35cda6335f8230c4168277b8dd'
2 parents a14393f + 12b6193 commit d539e78

File tree

270 files changed

+5977
-2534
lines changed

Some content is hidden

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

270 files changed

+5977
-2534
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
*.DS_Store
22
build/
3+
*.user
4+
5+
.vscode
6+
.idea

.travis.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
language: cpp
2+
cache: ccache
3+
sudo: required
4+
dist: trusty
5+
env:
6+
- JOB=DOCS
7+
- JOB=BUILD_AND_TEST
8+
addons:
9+
apt:
10+
packages:
11+
- gcc-4.8
12+
- g++-4.8
13+
- wget
14+
- git
15+
- build-essential
16+
- libatlas-base-dev
17+
- python
18+
- python-pip
19+
- python2.7-dev
20+
- m4
21+
- libprotobuf-dev
22+
- doxygen
23+
- protobuf-compiler
24+
- python-protobuf
25+
- python-numpy
26+
- python-wheel
27+
- libgoogle-glog-dev
28+
- libgflags-dev
29+
- libgtest-dev
30+
before_install:
31+
- pip install wheel protobuf sphinx breathe recommonmark
32+
- sudo paddle/scripts/travis/before_install.sh
33+
script:
34+
- paddle/scripts/travis/main.sh
35+
notifications:
36+
email:
37+
on_success: change
38+
on_failure: always

CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8)
33
project(paddle CXX C)
44
set(PADDLE_MAJOR_VERSION 0)
55
set(PADDLE_MINOR_VERSION 8)
6-
set(PADDLE_PATCH_VERSION 0b)
6+
set(PADDLE_PATCH_VERSION 0b1)
77
set(PADDLE_VERSION ${PADDLE_MAJOR_VERSION}.${PADDLE_MINOR_VERSION}.${PADDLE_PATCH_VERSION})
88

99
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
@@ -14,8 +14,10 @@ find_package(CUDA QUIET)
1414
find_package(Protobuf REQUIRED)
1515
find_package(PythonLibs 2.7 REQUIRED)
1616
find_package(PythonInterp 2.7 REQUIRED)
17-
find_package(NumPy)
17+
find_package(ZLIB REQUIRED)
18+
find_package(NumPy REQUIRED)
1819
find_package(Threads REQUIRED)
20+
find_package(AVX QUIET)
1921
find_package(Glog)
2022
find_package(Gflags QUIET)
2123
find_package(GTest)
@@ -27,7 +29,7 @@ find_program(M4_EXECUTABLE m4)
2729
option(WITH_DSO "Compile PaddlePaddle with dynamic linked libraries" ON)
2830
option(WITH_GPU "Compile PaddlePaddle with gpu" ${CUDA_FOUND})
2931
option(WITH_DOUBLE "Compile PaddlePaddle with double precision, otherwise use single precision" OFF)
30-
option(WITH_AVX "Compile PaddlePaddle with avx intrinsics" ON) # TODO(yuyang18): Check AVX is supported or not as default value
32+
option(WITH_AVX "Compile PaddlePaddle with avx intrinsics" ${AVX_FOUND})
3133
option(WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON)
3234
option(WITH_STYLE_CHECK "Style Check for PaddlePaddle" ${PYTHONINTERP_FOUND})
3335
option(WITH_RDMA "Compile PaddlePaddle with rdma support" OFF)
@@ -37,6 +39,7 @@ option(WITH_TIMER "Compile PaddlePaddle use timer" OFF)
3739
option(WITH_TESTING "Compile and run unittest for PaddlePaddle" ${GTEST_FOUND})
3840
option(WITH_DOC "Compile PaddlePaddle with documentation" OFF)
3941
option(WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" ${SWIG_FOUND})
42+
option(ON_TRAVIS "Running test on travis-ci or not." OFF)
4043
if(NOT CMAKE_BUILD_TYPE)
4144
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
4245
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
@@ -99,8 +102,8 @@ if(NOT WITH_TIMER)
99102
endif(NOT WITH_TIMER)
100103

101104
if(WITH_AVX)
102-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
103-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
105+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AVX_FLAGS}")
106+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX_FLAGS}")
104107
else(WITH_AVX)
105108
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
106109
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# PaddlePaddle
2+
[![Build Status](https://travis-ci.org/baidu/Paddle.svg?branch=master)](https://travis-ci.org/baidu/Paddle)
3+
4+
Welcome to the PaddlePaddle GitHub.
5+
6+
The software will be released on Sept. 30 with full documentation and installation support.
7+
8+
A pre-release version is available now for those who are eager to take a look.
29

310
PaddlePaddle (PArallel Distributed Deep LEarning) is an easy-to-use,
411
efficient, flexible and scalable deep learning platform, which is originally

cmake/FindAVX.cmake

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This file is use to check all support level of AVX on your machine
2+
# so that PaddlePaddle can unleash the vectorization power of muticore.
3+
4+
INCLUDE(CheckCXXSourceRuns)
5+
6+
SET(FIND_AVX_10)
7+
SET(FIND_AVX_20)
8+
SET(AVX_FLAGS)
9+
SET(AVX_FOUND)
10+
11+
# Check AVX 2
12+
SET(CMAKE_REQUIRED_FLAGS)
13+
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
14+
SET(CMAKE_REQUIRED_FLAGS "-mavx2")
15+
ELSEIF(MSVC AND NOT CMAKE_CL_64) # reserve for WINDOWS
16+
SET(CMAKE_REQUIRED_FLAGS "/arch:AVX2")
17+
ENDIF()
18+
19+
CHECK_CXX_SOURCE_RUNS("
20+
#include <immintrin.h>
21+
int main()
22+
{
23+
__m256i a = _mm256_set_epi32 (-1, 2, -3, 4, -1, 2, -3, 4);
24+
__m256i result = _mm256_abs_epi32 (a);
25+
return 0;
26+
}" FIND_AVX_20)
27+
28+
# Check AVX
29+
SET(CMAKE_REQUIRED_FLAGS)
30+
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
31+
SET(CMAKE_REQUIRED_FLAGS "-mavx")
32+
ELSEIF(MSVC AND NOT CMAKE_CL_64)
33+
SET(CMAKE_REQUIRED_FLAGS "/arch:AVX")
34+
endif()
35+
36+
CHECK_CXX_SOURCE_RUNS("
37+
#include <immintrin.h>
38+
int main()
39+
{
40+
__m256 a = _mm256_set_ps (-1.0f, 2.0f, -3.0f, 4.0f, -1.0f, 2.0f, -3.0f, 4.0f);
41+
__m256 b = _mm256_set_ps (1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f);
42+
__m256 result = _mm256_add_ps (a, b);
43+
return 0;
44+
}" FIND_AVX_10)
45+
46+
IF(${FIND_AVX_20})
47+
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
48+
SET(AVX_FLAGS "${AVX_FLAGS} -mavx2")
49+
ELSEIF(MSVC)
50+
SET(AVX_FLAGS "${AVX_FLAGS} /arch:AVX2")
51+
ENDIF()
52+
ENDIF()
53+
54+
IF(${FIND_AVX_10})
55+
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
56+
SET(AVX_FLAGS "${AVX_FLAGS} -mavx")
57+
ELSEIF(MSVC)
58+
SET(AVX_FLAGS "${AVX_FLAGS} /arch:AVX")
59+
ENDIF()
60+
ENDIF()
61+
62+
IF("${FIND_AVX_10}" OR "${FIND_AVX_20}")
63+
SET(AVX_FOUND TRUE)
64+
MESSAGE(STATUS "Find CPU supports ${AVX_FLAGS}.")
65+
ENDIF()

cmake/cblas.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ set(OPENBLAS_ROOT $ENV{OPENBLAS_ROOT} CACHE PATH "Folder contains Openblas")
6565
set(OPENBLAS_INCLUDE_SEARCH_PATHS
6666
${OPENBLAS_ROOT}/include
6767
/usr/include
68-
/usr/include/openblas)
68+
/usr/include/openblas
69+
/usr/local/opt/openblas/include)
6970
set(OPENBLAS_LIB_SEARCH_PATHS
7071
${OPENBLAS_ROOT}/lib
7172
/usr/lib
7273
/usr/lib/blas/openblas
73-
/usr/lib/openblas)
74+
/usr/lib/openblas
75+
/usr/local/opt/openblas/lib)
7476

7577
find_path(OPENBLAS_INC_DIR NAMES cblas.h
7678
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})

cmake/cudnn.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ list(APPEND CUDNN_CHECK_LIBRARY_DIRS
1515
$ENV{CUDNN_ROOT}/lib64
1616
$ENV{CUDNN_ROOT}/lib
1717
/usr/lib)
18-
find_library(CUDNN_LIBRARY NAMES libcudnn.so # libcudnn_static.a
18+
find_library(CUDNN_LIBRARY NAMES libcudnn.so libcudnn.dylib # libcudnn_static.a
1919
PATHS ${CUDNN_CHECK_LIBRARY_DIRS} ${CUDNN_INCLUDE_DIR} ${__libpath_hist}
2020
NO_DEFAULT_PATH
2121
DOC "Path to cuDNN library.")

cmake/flags.cmake

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include(CheckCXXSymbolExists)
88
# is_c: is C flag or C++ flag, bool type.
99
# src_list: The list name which the flag name will be append to.
1010
# flag_name: the flag name for compiler, such as '-Werror' '-Wall' etc
11-
# rest arguments: not used.
11+
# rest arguments: not used.
1212
function(safe_set_flag is_c src_list flag_name)
1313
string(REPLACE "-" "_" safe_name ${flag_name})
1414
string(REPLACE "=" "_" safe_name ${safe_name})
@@ -44,7 +44,7 @@ CHECK_CXX_SYMBOL_EXISTS(UINT64_MAX "stdint.h" UINT64_MAX_EXISTS)
4444
if(NOT UINT64_MAX_EXISTS)
4545
set(CMAKE_REQUIRED_DEFINITIONS -D__STDC_LIMIT_MACROS)
4646
CHECK_CXX_SYMBOL_EXISTS(UINT64_MAX "stdint.h" UINT64_MAX_EXISTS_HERE)
47-
if(UINT64_MAX_EXISTS_HERE)
47+
if(UINT64_MAX_EXISTS_HERE)
4848
set(CMAKE_REQUIRED_DEFINITIONS)
4949
add_definitions(-D__STDC_LIMIT_MACROS)
5050
else()
@@ -74,13 +74,37 @@ endforeach()
7474
# Release/Debug flags set by cmake. Such as -O3 -g -DNDEBUG etc.
7575
# So, don't set these flags here.
7676

77+
function(specify_cuda_arch cuda_version cuda_arch)
78+
if(${cuda_version} VERSION_GREATER "8.0")
79+
foreach(capability 61 62)
80+
if(${cuda_arch} STREQUAL ${capability})
81+
list(APPEND __arch_flags " -gencode arch=compute_${cuda_arch},code=sm_${cuda_arch}")
82+
endif()
83+
endforeach()
84+
elseif(${cuda_version} VERSION_GREATER "7.0" and ${cuda_arch} STREQUAL "53")
85+
list(APPEND __arch_flags " -gencode arch=compute_${cuda_arch},code=sm_${cuda_arch}")
86+
endif()
87+
endfunction()
88+
89+
# Common gpu architectures: Kepler, Maxwell
7790
foreach(capability 30 35 50)
78-
list(APPEND __arch_flags "-gencode arch=compute_${capability},code=sm_${capability}")
91+
list(APPEND __arch_flags " -gencode arch=compute_${capability},code=sm_${capability}")
7992
endforeach()
8093

8194
if (CUDA_VERSION VERSION_GREATER "7.0")
82-
list(APPEND __arch_flags "-gencode arch=compute_52,code=sm_52")
95+
list(APPEND __arch_flags " -gencode arch=compute_52,code=sm_52")
8396
endif()
8497

85-
set(CUDA_NVCC_FLAGS ${__arch_flags} ${CUDA_NVCC_FLAGS})
98+
# Modern gpu architectures: Pascal
99+
if (CUDA_VERSION VERSION_GREATER "8.0")
100+
list(APPEND __arch_flags " -gencode arch=compute_60,code=sm_60")
101+
endif()
86102

103+
# Custom gpu architecture
104+
set(CUDA_ARCH)
105+
106+
if(CUDA_ARCH)
107+
specify_cuda_arch(${CUDA_VERSION} ${CUDA_ARCH})
108+
endif()
109+
110+
set(CUDA_NVCC_FLAGS ${__arch_flags} ${CUDA_NVCC_FLAGS})

cmake/util.cmake

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,55 @@
11
# Some common routine for paddle compile.
22

3-
43
# target_circle_link_libraries
54
# Link libraries to target which has circle dependencies.
65
#
76
# First Argument: target name want to be linked with libraries
87
# Rest Arguments: libraries which link together.
98
function(target_circle_link_libraries TARGET_NAME)
10-
target_link_libraries(${TARGET_NAME}
11-
-Wl,--start-group
12-
${ARGN}
13-
-Wl,--end-group)
9+
if(APPLE)
10+
set(LIBS)
11+
set(inArchive OFF)
12+
set(libsInArgn)
13+
14+
foreach(arg ${ARGN})
15+
if(${arg} STREQUAL "ARCHIVE_START")
16+
set(inArchive ON)
17+
elseif(${arg} STREQUAL "ARCHIVE_END")
18+
set(inArchive OFF)
19+
else()
20+
if(inArchive)
21+
list(APPEND LIBS "-Wl,-force_load")
22+
endif()
23+
list(APPEND LIBS ${arg})
24+
list(APPEND libsInArgn ${arg})
25+
endif()
26+
endforeach()
27+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
28+
list(APPEND LIBS "-undefined dynamic_lookup")
29+
endif()
30+
list(REVERSE libsInArgn)
31+
target_link_libraries(${TARGET_NAME}
32+
${LIBS}
33+
${libsInArgn})
34+
35+
else() # LINUX
36+
set(LIBS)
37+
38+
foreach(arg ${ARGN})
39+
if(${arg} STREQUAL "ARCHIVE_START")
40+
list(APPEND LIBS "-Wl,--whole-archive")
41+
elseif(${arg} STREQUAL "ARCHIVE_END")
42+
list(APPEND LIBS "-Wl,--no-whole-archive")
43+
else()
44+
list(APPEND LIBS ${arg})
45+
endif()
46+
endforeach()
47+
48+
target_link_libraries(${TARGET_NAME}
49+
"-Wl,--start-group"
50+
${LIBS}
51+
"-Wl,--end-group")
52+
endif()
1453
endfunction()
1554

1655
# compile_cu_as_cpp
@@ -41,20 +80,20 @@ function(link_paddle_exe TARGET_NAME)
4180
if(PADDLE_WITH_INTERNAL)
4281
set(INTERAL_LIBS paddle_internal_gserver paddle_internal_parameter)
4382
target_circle_link_libraries(${TARGET_NAME}
44-
-Wl,--whole-archive
83+
ARCHIVE_START
4584
paddle_internal_gserver
4685
paddle_internal_owlqn
47-
-Wl,--no-whole-archive
86+
ARCHIVE_END
4887
paddle_internal_parameter)
4988
else()
5089
set(INTERAL_LIBS "")
5190
endif()
5291

5392
target_circle_link_libraries(${TARGET_NAME}
54-
-Wl,--whole-archive
93+
ARCHIVE_START
5594
paddle_gserver
5695
${METRIC_LIBS}
57-
-Wl,--no-whole-archive
96+
ARCHIVE_END
5897
paddle_pserver
5998
paddle_trainer_lib
6099
paddle_network
@@ -67,9 +106,9 @@ function(link_paddle_exe TARGET_NAME)
67106
${PROTOBUF_LIBRARY}
68107
${CMAKE_THREAD_LIBS_INIT}
69108
${CBLAS_LIBS}
70-
${CMAKE_DL_LIBS}
109+
${ZLIB_LIBRARIES}
71110
${INTERAL_LIBS}
72-
-lz)
111+
${CMAKE_DL_LIBS})
73112

74113
if(WITH_PYTHON)
75114
target_link_libraries(${TARGET_NAME}

demo/image_classification/prediction.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020

2121
import paddle.utils.image_util as image_util
2222

23-
from py_paddle import swig_paddle, util
24-
from py_paddle import DataProviderWrapperConverter
25-
from paddle.trainer.PyDataProviderWrapper import DenseSlot
23+
from py_paddle import swig_paddle, DataProviderConverter
24+
from paddle.trainer.PyDataProvider2 import dense_vector
2625
from paddle.trainer.config_parser import parse_config
2726

2827
logging.basicConfig(format='[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s')
@@ -75,8 +74,8 @@ def __init__(self,
7574
self.network.loadParameters(self.model_dir)
7675

7776
data_size = 3 * self.crop_dims[0] * self.crop_dims[1]
78-
slots = [DenseSlot(data_size)]
79-
self.converter = util.DataProviderWrapperConverter(False, slots)
77+
slots = [dense_vector(data_size)]
78+
self.converter = DataProviderConverter(slots)
8079

8180
def get_data(self, img_path):
8281
"""

0 commit comments

Comments
 (0)