Skip to content

Commit 5cedfb6

Browse files
committed
test=develop
2 parents 84d9300 + 8e2fdc5 commit 5cedfb6

File tree

145 files changed

+3719
-755
lines changed

Some content is hidden

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

145 files changed

+3719
-755
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ third_party/
2525
bazel-*
2626
third_party/
2727

28+
build_*
2829
# clion workspace.
2930
cmake-build-*

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ option(WITH_INFERENCE "Compile fluid inference library" ON)
7272
option(WITH_INFERENCE_API_TEST "Test fluid inference high-level api interface" OFF)
7373
option(WITH_SYSTEM_BLAS "Use system blas library" OFF)
7474
option(PY_VERSION "Compile PaddlePaddle with python3 support" ${PY_VERSION})
75+
option(WITH_FAST_MATH "Make use of fast math library, might affect the precision to some extent" ON)
7576

7677
# PY_VERSION
7778
if(NOT PY_VERSION)

Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ COPY ./paddle/scripts/docker/root/ /root/
2424

2525
RUN apt-get update && \
2626
apt-get install -y --allow-downgrades patchelf \
27+
python3 python3-dev python3-pip \
2728
git python-pip python-dev python-opencv openssh-server bison \
2829
libnccl2=2.1.2-1+cuda8.0 libnccl-dev=2.1.2-1+cuda8.0 \
2930
wget unzip unrar tar xz-utils bzip2 gzip coreutils ntp \
@@ -70,24 +71,33 @@ RUN localedef -i en_US -f UTF-8 en_US.UTF-8
7071
# specify sphinx version as 1.5.6 and remove -U option for [pip install -U
7172
# sphinx-rtd-theme] since -U option will cause sphinx being updated to newest
7273
# version(1.7.1 for now), which causes building documentation failed.
73-
RUN easy_install -U pip && \
74+
RUN pip3 install -U wheel && \
75+
pip3 install -U docopt PyYAML sphinx==1.5.6 && \
76+
pip3 install sphinx-rtd-theme==0.1.9 recommonmark && \
77+
easy_install -U pip && \
7478
pip install -U wheel && \
7579
pip install -U docopt PyYAML sphinx==1.5.6 && \
7680
pip install sphinx-rtd-theme==0.1.9 recommonmark
7781

78-
RUN pip install pre-commit 'ipython==5.3.0' && \
82+
RUN pip3 install pre-commit 'ipython==5.3.0' && \
83+
pip3 install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \
84+
pip3 install opencv-python && \
85+
pip install pre-commit 'ipython==5.3.0' && \
7986
pip install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \
8087
pip install opencv-python
8188

8289
#For docstring checker
90+
RUN pip3 install pylint pytest astroid isort
8391
RUN pip install pylint pytest astroid isort LinkChecker
8492

8593
COPY ./python/requirements.txt /root/
94+
RUN pip3 install -r /root/requirements.txt
8695
RUN pip install -r /root/requirements.txt
8796

8897
# To fix https://github.com/PaddlePaddle/Paddle/issues/1954, we use
8998
# the solution in https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2
9099
RUN apt-get install -y libssl-dev libffi-dev
100+
RUN pip3 install certifi urllib3[secure]
91101
RUN pip install certifi urllib3[secure]
92102

93103

cmake/cblas.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ set(OPENBLAS_LIB_SEARCH_PATHS
4040
/usr/local/opt/openblas/lib)
4141

4242
find_path(OPENBLAS_INC_DIR NAMES cblas.h
43-
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})
43+
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS} NO_DEFAULT_PATH)
4444
find_path(OPENBLAS_LAPACKE_INC_DIR NAMES lapacke.h
4545
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})
4646
find_library(OPENBLAS_LIB NAMES openblas

cmake/cuda.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
175175
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler -fPIC")
176176
endif(NOT WIN32)
177177

178-
list(APPEND CUDA_NVCC_FLAGS "--use_fast_math")
178+
if(WITH_FAST_MATH)
179+
# Make use of fast math library. https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html
180+
list(APPEND CUDA_NVCC_FLAGS "--use_fast_math")
181+
endif()
179182
# in cuda9, suppress cuda warning on eigen
180183
list(APPEND CUDA_NVCC_FLAGS "-w")
181184
# Set :expt-relaxed-constexpr to suppress Eigen warnings

cmake/external/eigen.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ INCLUDE(ExternalProject)
33
SET(EIGEN_SOURCE_DIR ${THIRD_PARTY_PATH}/eigen3)
44
SET(EIGEN_INCLUDE_DIR ${EIGEN_SOURCE_DIR}/src/extern_eigen3)
55
INCLUDE_DIRECTORIES(${EIGEN_INCLUDE_DIR})
6+
if(NOT WITH_FAST_MATH)
7+
# EIGEN_FAST_MATH: https://eigen.tuxfamily.org/dox/TopicPreprocessorDirectives.html
8+
# enables some optimizations which might affect the accuracy of the result.
9+
# This currently enables the SSE vectorization of sin() and cos(),
10+
# and speedups sqrt() for single precision.
11+
# Defined to 1 by default. Define it to 0 to disable.
12+
add_definitions(-DEIGEN_FAST_MATH=0)
13+
endif()
614

715
if(WITH_AMD_GPU)
816
ExternalProject_Add(

cmake/external/openblas.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ IF(NOT ${CBLAS_FOUND})
2727

2828
SET(CBLAS_SOURCES_DIR ${THIRD_PARTY_PATH}/openblas)
2929
SET(CBLAS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/openblas)
30-
SET(CBLAS_INCLUDE_DIR "${CBLAS_INSTALL_DIR}/include" CACHE PATH "openblas include directory." FORCE)
30+
SET(CBLAS_INC_DIR "${CBLAS_INSTALL_DIR}/include" CACHE PATH "openblas include directory." FORCE)
3131

3232
SET(CBLAS_LIBRARIES
3333
"${CBLAS_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}openblas${CMAKE_STATIC_LIBRARY_SUFFIX}"
@@ -96,7 +96,7 @@ IF(NOT ${CBLAS_FOUND})
9696
ENDIF(NOT WIN32)
9797
SET(CBLAS_PROVIDER openblas)
9898
IF(WITH_C_API)
99-
INSTALL(DIRECTORY ${CBLAS_INCLUDE_DIR} DESTINATION third_party/openblas)
99+
INSTALL(DIRECTORY ${CBLAS_INC_DIR} DESTINATION third_party/openblas)
100100
# Because libopenblas.a is a symbolic link of another library, thus need to
101101
# install the whole directory.
102102
IF(ANDROID)
@@ -117,8 +117,8 @@ IF(NOT ${CBLAS_FOUND})
117117
ENDIF(NOT ${CBLAS_FOUND})
118118

119119
MESSAGE(STATUS "BLAS library: ${CBLAS_LIBRARIES}")
120-
MESSAGE(STATUS "BLAS Include: ${CBLAS_INCLUDE_DIR}")
121-
INCLUDE_DIRECTORIES(${CBLAS_INCLUDE_DIR})
120+
MESSAGE(STATUS "BLAS Include: ${CBLAS_INC_DIR}")
121+
INCLUDE_DIRECTORIES(${CBLAS_INC_DIR})
122122

123123
# FIXME(gangliao): generate cblas target to track all high performance
124124
# linear algebra libraries for cc_library(xxx SRCS xxx.c DEPS cblas)

cmake/flags.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ if (APPLE)
157157
# On Mac OS X build fat binaries with x86_64 architectures by default.
158158
set (CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)
159159
endif()
160+
# On Mac OS X register class specifier is deprecated and will cause warning error on latest clang 10.0
161+
set (COMMON_FLAGS -Wno-deprecated-register)
160162
endif(APPLE)
161163

162164
if(LINUX)

paddle/fluid/API.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ paddle.fluid.layers.argsort ArgSpec(args=['input', 'axis', 'name'], varargs=None
198198
paddle.fluid.layers.ones ArgSpec(args=['shape', 'dtype', 'force_cpu'], varargs=None, keywords=None, defaults=(False,))
199199
paddle.fluid.layers.zeros ArgSpec(args=['shape', 'dtype', 'force_cpu'], varargs=None, keywords=None, defaults=(False,))
200200
paddle.fluid.layers.reverse ArgSpec(args=['x', 'axis'], varargs=None, keywords=None, defaults=None)
201+
paddle.fluid.layers.has_inf ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
202+
paddle.fluid.layers.has_nan ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
203+
paddle.fluid.layers.isfinite ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
201204
paddle.fluid.layers.While.__init__ ArgSpec(args=['self', 'cond', 'is_test', 'name'], varargs=None, keywords=None, defaults=(False, None))
202205
paddle.fluid.layers.While.block ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None)
203206
paddle.fluid.layers.Switch.__init__ ArgSpec(args=['self', 'name'], varargs=None, keywords=None, defaults=(None,))

paddle/fluid/framework/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# windows treat symbolic file as a real file, which is different with unix
23
# We create a hidden file and compile it instead of origin source file.
34
function(windows_symbolic TARGET)
@@ -9,11 +10,23 @@ function(windows_symbolic TARGET)
910
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc OR NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cu)
1011
message(FATAL " ${src}.cc and ${src}.cu must exsits, and ${src}.cu must be symbolic file.")
1112
endif()
12-
add_custom_command(OUTPUT .${src}.cu
13+
14+
# only copy the xx.cu to .xx.cu when the content are modified
15+
set(copy_flag 1)
16+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu)
17+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc SOURCE_STR)
18+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu TARGET_STR)
19+
if (SOURCE_STR STREQUAL TARGET_STR)
20+
set(copy_flag 0)
21+
endif()
22+
endif()
23+
if (copy_flag)
24+
add_custom_command(OUTPUT .${src}.cu
1325
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu
1426
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc" "${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu"
1527
COMMENT "create hidden file of ${src}.cu")
16-
add_custom_target(${TARGET} ALL DEPENDS .${src}.cu)
28+
endif(copy_flag)
29+
add_custom_target(${TARGET} ALL DEPENDS .${src}.cu)
1730
endforeach()
1831
endfunction()
1932

@@ -81,6 +94,8 @@ nv_test(data_device_transform_test SRCS data_device_transform_test.cu
8194

8295
if(WITH_GPU)
8396
if (WIN32)
97+
# windows treat symbolic file as a real file, which is different with unix
98+
# We create a hidden file and compile it instead of origin source file.
8499
windows_symbolic(hidden_file SRCS data_type_transform.cu)
85100
nv_library(data_type_transform SRCS .data_type_transform.cu DEPS tensor)
86101
add_dependencies(data_type_transform hidden_file)
@@ -149,7 +164,7 @@ if(WITH_DISTRIBUTE)
149164
set_source_files_properties(executor.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
150165
else()
151166
cc_library(executor SRCS executor.cc DEPS op_registry device_context scope framework_proto glog lod_rank_table feed_fetch_method graph_to_program_pass)
152-
cc_test(test_naive_executor SRCS naive_executor_test.cc DEPS naive_executor op_registry device_context scope framework_proto glog lod_rank_table feed_fetch_method graph_to_program_pass elementwise_add_op)
167+
cc_test(test_naive_executor SRCS naive_executor_test.cc DEPS naive_executor elementwise_add_op)
153168
endif()
154169

155170
if (NOT WIN32)

0 commit comments

Comments
 (0)