Skip to content

Commit 6e735e1

Browse files
committed
Merge branch 'develop' into merge_bn
2 parents 7815cdf + f7a54b5 commit 6e735e1

File tree

144 files changed

+2065
-3631
lines changed

Some content is hidden

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

144 files changed

+2065
-3631
lines changed

benchmark/fluid/mnist.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ def run_benchmark(model, args):
139139

140140
# inference program
141141
inference_program = fluid.default_main_program().clone()
142-
with fluid.program_guard(inference_program):
143-
inference_program = fluid.io.get_inference_program(
144-
target_vars=[batch_acc, batch_size_tensor])
145142

146143
# Optimization
147144
opt = fluid.optimizer.AdamOptimizer(
@@ -161,7 +158,7 @@ def run_benchmark(model, args):
161158
train_reader = paddle.batch(
162159
paddle.dataset.mnist.train(), batch_size=args.batch_size)
163160

164-
accuracy = fluid.average.WeightedAverage()
161+
accuracy = fluid.metrics.Accuracy()
165162
iters, num_samples, start_time = 0, 0, time.time()
166163
for pass_id in range(args.pass_num):
167164
accuracy.reset()
@@ -184,7 +181,7 @@ def run_benchmark(model, args):
184181
"label": y_data},
185182
fetch_list=[avg_cost, batch_acc, batch_size_tensor]
186183
) # The accuracy is the accumulation of batches, but not the current batch.
187-
accuracy.add(value=outs[1], weight=outs[2])
184+
accuracy.update(value=outs[1], weight=outs[2])
188185
iters += 1
189186
num_samples += len(y_data)
190187
loss = np.array(outs[0])

cmake/cblas.cmake

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,33 @@ endif()
6262

6363

6464
## Then find the reference-cblas. www.netlib.org/blas/
65-
66-
6765
set(REFERENCE_CBLAS_ROOT $ENV{REFERENCE_CBLAS_ROOT} CACHE PATH
6866
"Folder contains reference-cblas")
69-
set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS
70-
${REFERENCE_CBLAS_ROOT}/include
71-
/usr/include
72-
/usr/include/cblas
73-
)
74-
75-
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS
76-
${REFERENCE_CBLAS_ROOT}/lib
77-
/usr/lib
78-
/usr/lib/blas/reference/
79-
/usr/lib/reference/
80-
)
67+
if(NOT CMAKE_CROSSCOMPILING)
68+
set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS
69+
${REFERENCE_CBLAS_ROOT}/include
70+
/usr/include
71+
/usr/include/cblas
72+
)
73+
74+
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS
75+
${REFERENCE_CBLAS_ROOT}/lib
76+
/usr/lib
77+
/usr/lib/blas/reference/
78+
/usr/lib/reference/
79+
)
80+
else()
81+
# Diable the finding of reference cblas under host's system path
82+
set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS ${REFERENCE_CBLAS_ROOT}/include)
83+
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS ${REFERENCE_CBLAS_ROOT}/lib)
84+
endif()
8185

8286
find_path(REFERENCE_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS
8387
${REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS})
8488
find_library(REFERENCE_CBLAS_LIBRARY NAMES cblas PATHS
8589
${REFERENCE_CBLAS_LIB_SEARCH_PATHS})
8690

87-
if (REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
91+
if(REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
8892
set(CBLAS_FOUND ON)
8993
set(CBLAS_PROVIDER REFERENCE)
9094
set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR})

cmake/external/grpc.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ SET(GRPC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/grpc)
2424
SET(GRPC_INCLUDE_DIR "${GRPC_INSTALL_DIR}/include/" CACHE PATH "grpc include directory." FORCE)
2525
SET(GRPC_CPP_PLUGIN "${GRPC_INSTALL_DIR}/bin/grpc_cpp_plugin" CACHE FILEPATH "GRPC_CPP_PLUGIN" FORCE)
2626
IF(APPLE)
27-
SET(BUILD_CMD make -n HAS_SYSTEM_PROTOBUF=false -s -j8 static grpc_cpp_plugin | sed "s/-Werror//g" | sh)
27+
SET(BUILD_CMD make -n HAS_SYSTEM_PROTOBUF=false -s -j static grpc_cpp_plugin | sed "s/-Werror//g" | sh)
2828
ELSE()
29-
SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j8 static grpc_cpp_plugin)
29+
SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j static grpc_cpp_plugin)
3030
ENDIF()
3131

3232
ExternalProject_Add(
3333
extern_grpc
3434
DEPENDS protobuf zlib
3535
GIT_REPOSITORY "https://github.com/grpc/grpc.git"
36-
GIT_TAG "v1.8.x"
36+
GIT_TAG "v1.11.x"
3737
PREFIX ${GRPC_SOURCES_DIR}
3838
UPDATE_COMMAND ""
3939
CONFIGURE_COMMAND ""

cmake/external/nccl.cmake

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

cmake/external/snappy.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
1514

16-
IF(MOBILE_INFERENCE)
15+
if(MOBILE_INFERENCE OR RPI)
1716
return()
18-
ENDIF()
17+
endif()
1918

2019
include (ExternalProject)
2120

2221
# NOTE: snappy is needed when linking with recordio
2322

24-
SET(SNAPPY_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy)
25-
SET(SNAPPY_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy)
26-
SET(SNAPPY_INCLUDE_DIR "${SNAPPY_INSTALL_DIR}/include/" CACHE PATH "snappy include directory." FORCE)
23+
set(SNAPPY_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy)
24+
set(SNAPPY_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy)
25+
set(SNAPPY_INCLUDE_DIR "${SNAPPY_INSTALL_DIR}/include" CACHE PATH "snappy include directory." FORCE)
26+
27+
set(SNAPPY_LIBRARIES "${SNAPPY_INSTALL_DIR}/lib/libsnappy.a")
2728

2829
ExternalProject_Add(
2930
extern_snappy
@@ -51,8 +52,7 @@ ExternalProject_Add(
5152
)
5253

5354
add_library(snappy STATIC IMPORTED GLOBAL)
54-
set_property(TARGET snappy PROPERTY IMPORTED_LOCATION
55-
"${SNAPPY_INSTALL_DIR}/lib/libsnappy.a")
55+
set_property(TARGET snappy PROPERTY IMPORTED_LOCATION ${SNAPPY_LIBRARIES})
5656

5757
include_directories(${SNAPPY_INCLUDE_DIR})
5858
add_dependencies(snappy extern_snappy)

cmake/external/snappystream.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
1514

16-
IF(MOBILE_INFERENCE)
15+
IF(MOBILE_INFERENCE OR RPI)
1716
return()
1817
ENDIF()
1918

2019
include (ExternalProject)
2120

2221
# NOTE: snappy is needed when linking with recordio
2322

24-
SET(SNAPPYSTREAM_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy_stream)
25-
SET(SNAPPYSTREAM_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy_stream)
26-
SET(SNAPPYSTREAM_INCLUDE_DIR "${SNAPPYSTREAM_INSTALL_DIR}/include/" CACHE PATH "snappy stream include directory." FORCE)
23+
set(SNAPPYSTREAM_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy_stream)
24+
set(SNAPPYSTREAM_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy_stream)
25+
set(SNAPPYSTREAM_INCLUDE_DIR "${SNAPPYSTREAM_INSTALL_DIR}/include" CACHE PATH "snappy stream include directory." FORCE)
26+
27+
set(SNAPPYSTREAM_LIBRARIES "${SNAPPYSTREAM_INSTALL_DIR}/lib/libsnappystream.a")
2728

2829
ExternalProject_Add(
2930
extern_snappystream
@@ -51,8 +52,7 @@ ExternalProject_Add(
5152
)
5253

5354
add_library(snappystream STATIC IMPORTED GLOBAL)
54-
set_property(TARGET snappystream PROPERTY IMPORTED_LOCATION
55-
"${SNAPPYSTREAM_INSTALL_DIR}/lib/libsnappystream.a")
55+
set_property(TARGET snappystream PROPERTY IMPORTED_LOCATION ${SNAPPYSTREAM_LIBRARIES})
5656

5757
include_directories(${SNAPPYSTREAM_INCLUDE_DIR}) # For snappysteam to include its own headers.
5858
include_directories(${THIRD_PARTY_PATH}/install) # For Paddle to include snappy stream headers.

cmake/generic.cmake

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,7 @@ function(cc_library TARGET_NAME)
195195
list(REMOVE_ITEM cc_library_DEPS warpctc)
196196
add_dependencies(${TARGET_NAME} warpctc)
197197
endif()
198-
if("${cc_library_DEPS}" MATCHES "ARCHIVE_START")
199-
# Support linking flags: --whole-archive (Linux) / -force_load (MacOS).
200-
# WARNING: Please don't use ARCHIVE_START&ARCHIVE_END if TARGET_NAME will be linked by other libraries.
201-
target_circle_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
202-
list(REMOVE_ITEM cc_library_DEPS ARCHIVE_START ARCHIVE_END)
203-
else()
204-
target_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
205-
endif()
198+
target_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
206199
add_dependencies(${TARGET_NAME} ${cc_library_DEPS})
207200
endif()
208201

@@ -243,11 +236,7 @@ function(cc_test TARGET_NAME)
243236
set(multiValueArgs SRCS DEPS ARGS)
244237
cmake_parse_arguments(cc_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
245238
add_executable(${TARGET_NAME} ${cc_test_SRCS})
246-
# Support linking flags: --whole-archive (Linux) / -force_load (MacOS)
247-
target_circle_link_libraries(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main memory gtest gflags glog)
248-
if("${cc_test_DEPS}" MATCHES "ARCHIVE_START")
249-
list(REMOVE_ITEM cc_test_DEPS ARCHIVE_START ARCHIVE_END)
250-
endif()
239+
target_link_libraries(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main memory gtest gflags glog)
251240
add_dependencies(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main memory gtest gflags glog)
252241
add_test(NAME ${TARGET_NAME}
253242
COMMAND ${TARGET_NAME} ${cc_test_ARGS}

cmake/inference_lib.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
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+
115
set_property(GLOBAL PROPERTY FLUID_MODULES "")
216
# find all fluid modules is used for paddle fluid static library
317
function(find_fluid_modules TARGET_NAME)
418
get_filename_component(__target_path ${TARGET_NAME} ABSOLUTE)
19+
string(REGEX REPLACE "^${PADDLE_SOURCE_DIR}/" "" __target_path ${__target_path})
520
string(FIND "${__target_path}" "fluid" pos)
621
if(pos GREATER 1)
722
get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
@@ -77,6 +92,23 @@ elseif (WITH_MKLML)
7792
)
7893
endif()
7994

95+
if(NOT MOBILE_INFERENCE AND NOT RPI)
96+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/snappy")
97+
copy(snappy_lib
98+
SRCS ${SNAPPY_INCLUDE_DIR} ${SNAPPY_LIBRARIES}
99+
DSTS ${dst_dir} ${dst_dir}/lib)
100+
101+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/snappystream")
102+
copy(snappystream_lib
103+
SRCS ${SNAPPYSTREAM_INCLUDE_DIR} ${SNAPPYSTREAM_LIBRARIES}
104+
DSTS ${dst_dir} ${dst_dir}/lib)
105+
106+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/zlib")
107+
copy(zlib_lib
108+
SRCS ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARIES}
109+
DSTS ${dst_dir} ${dst_dir}/lib)
110+
endif()
111+
80112
# paddle fluid module
81113
set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
82114
set(dst_dir "${CMAKE_INSTALL_PREFIX}/paddle/fluid")

doc/fluid/design/motivation/fluid.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ An actual Fluid example is described [here](https://github.com/PaddlePaddle/Pad
119119

120120
From the example, the Fluid programs look very similar to their PyTorch equivalent programs, except that Fluid's loop structure, wrapped with Python's `with` statement, could run much faster than just a Python loop.
121121

122-
We have more examples of the [`if-then-else`](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/if_else_op.md) structure of Fluid.
122+
We have more examples of the [`if-then-else`](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/fluid/design/execution/if_else_op.md) structure of Fluid.
123123

124124
## Turing Completeness
125125

doc/v2/dev/write_docs_cn.rst

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,39 +65,55 @@ PaddlePaddle.org工具可以配合Docker使用,需要在系统里先安装好D
6565
不使用PaddlePaddle.org工具
6666
--------------------------
6767

68-
使用Docker构建PaddlePaddle的文档,需要在系统里先安装好Docker工具包。Docker安装请参考 `Docker的官网 <https://docs.docker.com/>`_ 。安装好Docker之后可以使用源码目录下的脚本构建文档,即
68+
使用Docker构建PaddlePaddle的文档,需要在系统里先安装好Docker工具包。Docker安装请参考 `Docker的官网 <https://docs.docker.com/>`_ 。该方法与 `从源码编译PaddlePaddle <http://paddlepaddle.org/docs/develop/documentation/zh/build_and_install/build_from_source_cn.html>`_ 相似,通过从源码中构建可用于编译PaddlePaddle文档的Docker镜像并运行,在进入Docker容器后使用源码中的脚本构建PaddlePaddle文档,具体步骤如下:
6969

70-
[TBD]
70+
.. code-block:: bash
71+
72+
git clone https://github.com/PaddlePaddle/Paddle.git
73+
cd Paddle
74+
75+
# 从源码中构建可用于编译PaddlePaddle文档的Docker镜像
76+
docker build -t paddle:dev .
77+
docker run -it -v $PWD:/paddle -e "WITH_GPU=OFF" -e "WITH_TESTING=OFF" -e "WITH_DOC=ON" paddle:dev /bin/bash
78+
79+
# 进入Docker容器后使用build.sh脚本构建PaddlePaddle文档
80+
bash -x /paddle/paddle/scripts/docker/build.sh
81+
82+
注:上述命令把当前目录(源码根目录)映射为 container 里的 :code:`/paddle` 目录。
83+
84+
编译完成后,会产生 ``doc/v2`` 和 ``doc/fluid`` 两个目录,在这两个目录下分别都生成 ``cn/html/`` 、 ``en/html`` 、 ``api/en/html`` 共三个子目录,分别进入这些目录下,执行以下命令:
85+
86+
.. code-block:: bash
87+
88+
python -m SimpleHTTPServer 8088
89+
90+
在浏览器中输入 http://localhost:8088 就可以看到编译生成的 ``v2`` 和 ``fluid`` 两种版本的中/英文的文档页面和英文的API页面。
7191

7292
如果不想使用Docker,也可以使用以下命令直接构建PaddlePaddle文档,即
7393

7494
.. code-block:: bash
7595
76-
mkdir paddle
77-
cd paddle
7896
git clone https://github.com/PaddlePaddle/Paddle.git
97+
cd Paddle
7998
mkdir -p build
8099
cd build
81100
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_GPU=OFF -DWITH_MKL=OFF -DWITH_DOC=ON
82101
83102
# 如果只需要构建使用文档,则执行以下命令
84-
make -j $processors gen_proto_py
85-
make -j $processors paddle_docs paddle_docs_cn
103+
make -j $processors paddle_docs
86104
87105
# 如果只需要构建API,则执行以下命令
88-
make -j $processors gen_proto_py framework_py_proto
89-
make -j $processors copy_paddle_pybind
90-
make -j $processors paddle_api_docs
106+
make -j $processors paddle_apis
91107
92108
其中$processors代表启动和CPU核一样多的进程来并行编译,可以根据本机的CPU核数设置相应的值。
93109

94-
编译完成后,进入 ``doc/v2`` 目录,如果选择构建文档则会在该目录下生成 ``cn/html/`` 、 ``en/html`` 两个子目录,选择构建API则会生成 ``api/en/html`` 目录,分别进入这些目录下,执行以下命令:
110+
编译完成后,同样会产生 ``doc/v2`` 和 ``doc/fluid`` 两个目录,如果选择构建文档则会在这两个目录下分别都生成 ``cn/html/`` 、 ``en/html`` 两个子目录,选择构建API则会在这两个目录下分别生成 ``api/en/html`` 目录,分别进入这些子目录下,执行以下命令:
95111

96112
.. code-block:: bash
97113
98114
python -m SimpleHTTPServer 8088
99115
100-
在浏览器中输入 http://localhost:8088 就可以看到编译生成的中/英文的文档页面和英文的API页面,下图为生成的英文文档首页示例。注意,示例中由于使用了sphinx的原始主题,所以页面的风格与官网并不一致,但这并不影响开发者进行调试。
116+
在浏览器中输入 http://localhost:8088 就可以看到编译生成的 ``v2`` 和 ``fluid`` 两种版本的中/英文的文档页面和英文的API页面。下图为生成的 ``v2`` 英文文档首页示例。注意,示例中由于使用了sphinx的原始主题,所以页面的风格与官网并不一致,但这并不影响开发者进行调试。
101117

102118
.. image:: src/doc_en.png
103119
:align: center

0 commit comments

Comments
 (0)