Skip to content

Commit 3df99e7

Browse files
committed
Merge remote-tracking branch 'ups/develop' into refine/set_num_threads
fix conflicts
2 parents e3a9630 + 4ed0b62 commit 3df99e7

File tree

1,034 files changed

+6151
-2344
lines changed

Some content is hidden

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

1,034 files changed

+6151
-2344
lines changed

CMakeLists.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ option(EIGEN_USE_THREADS "Compile with multi-threaded Eigen" OFF)
6161
option(WITH_ARM_FP16 "Use half precision support on armv8.2-a cpu" OFF)
6262
option(WITH_FAST_BUNDLE_TEST "Bundle tests that can be run in a single process together to reduce launch overhead" OFF)
6363
option(WITH_CONTRIB "Compile the third-party contributation" OFF)
64+
option(REPLACE_ENFORCE_GLOG "Replace PADDLE_ENFORCE with glog/CHECK for better debug." OFF)
6465
option(WITH_ANAKIN "Compile with Anakin library" OFF)
6566
option(WITH_GRPC "Use grpc as the default rpc framework" ${WITH_DISTRIBUTE})
67+
option(WITH_BRPC_RDMA "Use brpc rdma as the rpc protocal" OFF)
68+
option(WITH_SYSTEM_BLAS "Use system blas library" OFF)
6669

6770
# CMAKE_BUILD_TYPE
6871
if(NOT CMAKE_BUILD_TYPE)
@@ -131,6 +134,10 @@ if (NOT DEFINED WITH_MKLDNN)
131134
set(WITH_MKLDNN OFF)
132135
endif()
133136
endif()
137+
138+
if (REPLACE_ENFORCE_GLOG)
139+
add_definitions("-DREPLACE_ENFORCE_GLOG")
140+
endif()
134141
########################################################################################
135142

136143
include(external/mklml) # download mklml package
@@ -153,12 +160,24 @@ include(external/cares)
153160
if(WITH_DISTRIBUTE)
154161
if(WITH_GRPC)
155162
include(external/grpc)
163+
message(STATUS "Use grpc framework.")
156164
else()
165+
message(STATUS "Use brpc framework.")
157166
include(external/leveldb)
158167
include(external/brpc)
159168
endif()
160169
endif()
161170

171+
if(WITH_BRPC_RDMA)
172+
message(STATUS "Use brpc with rdma.")
173+
if(WITH_GRPC)
174+
message(FATAL_ERROR "Can't use grpc with brpc rdma.")
175+
endif()
176+
if(NOT WITH_DISTRIBUTE)
177+
message(FATAL_ERROR "Can't use brpc rdma in no distribute env.")
178+
endif()
179+
endif()
180+
162181
include(external/snappy) # download snappy
163182
include(external/snappystream)
164183
include(external/threadpool)
@@ -178,7 +197,7 @@ include(inference_lib) # add paddle fluid inference libraries
178197

179198

180199
include_directories("${PADDLE_SOURCE_DIR}")
181-
include_directories("${PADDLE_SOURCE_DIR}/paddle/cuda/include")
200+
include_directories("${PADDLE_SOURCE_DIR}/paddle/legacy/cuda/include")
182201
include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto")
183202
include_directories("${CMAKE_CURRENT_BINARY_DIR}/go/pserver/client/c")
184203

@@ -222,7 +241,7 @@ add_subdirectory(proto)
222241
if(NOT MOBILE_INFERENCE AND NOT WITH_FLUID_ONLY)
223242
# "add_subdirectory(go)" should be placed after the following loine,
224243
# because it depends on paddle/optimizer.
225-
add_subdirectory(paddle/optimizer)
244+
add_subdirectory(paddle/legacy/optimizer)
226245
endif()
227246

228247
# "add_subdirectory(paddle)" and "add_subdirectory(python)" should be

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ This will enable VLOG messages generated by `buddy_allocator.{h,cc}` and in the
159159
- verbose level 1: [framework](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/framework)
160160
- verbose level 3: [operators](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/operators)
161161
- verbose level 5: [memory](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/memory), [platform](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/platform)
162-
- verbose level 7: [math](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/math)
162+
- verbose level 7: [math](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/legacy/math)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[![Build Status](https://travis-ci.org/PaddlePaddle/Paddle.svg?branch=develop)](https://travis-ci.org/PaddlePaddle/Paddle)
55
[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://www.paddlepaddle.org/docs/develop/documentation/en/getstarted/index_en.html)
66
[![Documentation Status](https://img.shields.io/badge/中文文档-最新-brightgreen.svg)](http://www.paddlepaddle.org/docs/develop/documentation/zh/getstarted/index_cn.html)
7-
[![Coverage Status](https://coveralls.io/repos/github/PaddlePaddle/Paddle/badge.svg?branch=develop)](https://coveralls.io/github/PaddlePaddle/Paddle?branch=develop)
87
[![Release](https://img.shields.io/github/release/PaddlePaddle/Paddle.svg)](https://github.com/PaddlePaddle/Paddle/releases)
98
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE)
109

@@ -19,6 +18,8 @@ learning to many products at Baidu.
1918
Our vision is to enable deep learning for everyone via PaddlePaddle.
2019
Please refer to our [release announcement](https://github.com/PaddlePaddle/Paddle/releases) to track the latest feature of PaddlePaddle.
2120

21+
### Lastest PaddlePaddle Version: [Fluid](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/fluid)
22+
2223
## Features
2324

2425
- **Flexibility**

benchmark/fluid/args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,13 @@ def parse_args():
122122
type=str,
123123
default="",
124124
help='Directory that contains all the training recordio files.')
125+
parser.add_argument(
126+
'--use_inference_transpiler',
127+
action='store_true',
128+
help='If set, use inference transpiler to optimize the program.')
129+
parser.add_argument(
130+
'--no_random',
131+
action='store_true',
132+
help='If set, keep the random seed and do not shuffle the data.')
125133
args = parser.parse_args()
126134
return args

benchmark/fluid/fluid_benchmark.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def train(avg_loss, infer_prog, optimizer, train_reader, test_reader, batch_acc,
131131
exe = fluid.Executor(place)
132132
exe.run(startup_prog)
133133

134+
# Use inference_transpiler to speedup
134135
if not args.use_reader_op:
135136
feed_var_list = [
136137
var for var in train_prog.global_block().vars.itervalues()
@@ -181,6 +182,10 @@ def train(avg_loss, infer_prog, optimizer, train_reader, test_reader, batch_acc,
181182
print("Pass: %d, Loss: %f" % (pass_id, np.mean(train_losses))),
182183
# evaluation
183184
if not args.no_test and batch_acc and not args.use_reader_op:
185+
if args.use_inference_transpiler:
186+
t = fluid.InferenceTranspiler()
187+
t.transpile(infer_prog, place)
188+
184189
pass_test_acc = test(exe, infer_prog, test_reader, feeder,
185190
batch_acc)
186191
print(", Test Accuracy: %f" % pass_test_acc)
@@ -311,6 +316,8 @@ def main():
311316
args = parse_args()
312317
print_arguments(args)
313318
print_paddle_envs()
319+
if args.no_random:
320+
fluid.default_startup_program().random_seed = 1
314321

315322
# the unique trainer id, starting from 0, needed by trainer
316323
# only

benchmark/fluid/models/resnet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ def get_model(args):
197197
optimizer = fluid.optimizer.Momentum(learning_rate=0.01, momentum=0.9)
198198

199199
batched_train_reader = paddle.batch(
200-
paddle.reader.shuffle(
200+
train_reader if args.no_random else paddle.reader.shuffle(
201201
train_reader, buf_size=5120),
202202
batch_size=args.batch_size * args.gpus,
203203
drop_last=True)
204204
batched_test_reader = paddle.batch(
205-
train_reader, batch_size=args.batch_size, drop_last=True)
205+
test_reader, batch_size=args.batch_size, drop_last=True)
206206

207207
return avg_cost, inference_program, optimizer, batched_train_reader,\
208208
batched_test_reader, batch_acc

cmake/cblas.cmake

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,20 @@ else()
8383
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS ${REFERENCE_CBLAS_ROOT}/lib)
8484
endif()
8585

86-
find_path(REFERENCE_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS
86+
if(WITH_SYSTEM_BLAS)
87+
find_path(REFERENCE_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS
8788
${REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS})
88-
find_library(REFERENCE_CBLAS_LIBRARY NAMES cblas PATHS
89+
find_library(REFERENCE_CBLAS_LIBRARY NAMES cblas PATHS
8990
${REFERENCE_CBLAS_LIB_SEARCH_PATHS})
9091

91-
if(REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
92-
set(CBLAS_FOUND ON)
93-
set(CBLAS_PROVIDER REFERENCE)
94-
set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR})
95-
set(CBLAS_LIBRARIES ${REFERENCE_CBLAS_LIBRARY})
96-
add_definitions(-DPADDLE_USE_REFERENCE_CBLAS)
97-
message(STATUS "Found reference-cblas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
92+
if(REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
93+
set(CBLAS_FOUND ON)
94+
set(CBLAS_PROVIDER REFERENCE)
95+
set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR})
96+
set(CBLAS_LIBRARIES ${REFERENCE_CBLAS_LIBRARY})
97+
add_definitions(-DPADDLE_USE_REFERENCE_CBLAS)
98+
message(STATUS "Found reference-cblas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
99+
endif()
98100
endif()
99101

100102
if(IOS_USE_VECLIB_FOR_BLAS AND VECLIB_FOUND)

cmake/configure.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,7 @@ endif(WITH_GOLANG)
174174
if(WITH_GRPC)
175175
add_definitions(-DPADDLE_WITH_GRPC)
176176
endif(WITH_GRPC)
177+
178+
if(WITH_BRPC_RDMA)
179+
add_definitions(-DPADDLE_WITH_BRPC_RDMA)
180+
endif(WITH_BRPC_RDMA)

cmake/external/anakin.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ function(fetch_include_recursively root_dir)
2626
endforeach()
2727
endfunction()
2828

29-
# download library
30-
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
31-
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
32-
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
33-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget -q ${ANAKIN_LIBRARY_URL}")
34-
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
35-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin_release_simple.tar.gz")
29+
if (NOT EXISTS "${ANAKIN_INSTALL_DIR}")
30+
# download library
31+
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
32+
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
33+
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
34+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget -q ${ANAKIN_LIBRARY_URL}")
35+
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
36+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin_release_simple.tar.gz")
37+
endif()
3638

3739
if (WITH_ANAKIN)
3840
message(STATUS "Anakin for inference is enabled")

cmake/external/brpc.cmake

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515
INCLUDE(ExternalProject)
1616

17+
find_library(SSL_LIBRARY NAMES ssl)
18+
ADD_LIBRARY(ssl SHARED IMPORTED GLOBAL)
19+
SET_PROPERTY(TARGET ssl PROPERTY IMPORTED_LOCATION ${SSL_LIBRARY})
20+
21+
find_library(CRYPTO_LIBRARY NAMES crypto)
22+
ADD_LIBRARY(crypto SHARED IMPORTED GLOBAL)
23+
SET_PROPERTY(TARGET crypto PROPERTY IMPORTED_LOCATION ${CRYPTO_LIBRARY})
24+
25+
1726
SET(BRPC_SOURCES_DIR ${THIRD_PARTY_PATH}/brpc)
1827
SET(BRPC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/brpc)
1928
SET(BRPC_INCLUDE_DIR "${BRPC_INSTALL_DIR}/include" CACHE PATH "brpc include directory." FORCE)
@@ -22,14 +31,14 @@ SET(BRPC_LIBRARIES "${BRPC_INSTALL_DIR}/lib/libbrpc.a" CACHE FILEPATH "brpc libr
2231
INCLUDE_DIRECTORIES(${BRPC_INCLUDE_DIR})
2332

2433
# Reference https://stackoverflow.com/questions/45414507/pass-a-list-of-prefix-paths-to-externalproject-add-in-cmake-args
25-
set(prefix_path "${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf")
34+
set(prefix_path "${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf|${THIRD_PARTY_PATH}/install/zlib")
2635

2736
# If minimal .a is need, you can set WITH_DEBUG_SYMBOLS=OFF
2837
ExternalProject_Add(
2938
extern_brpc
3039
${EXTERNAL_PROJECT_LOG_ARGS}
31-
GIT_REPOSITORY "https://github.com/brpc/brpc"
32-
GIT_TAG "6d153dd7ff00f960ae6895c9c5fff0ce9f07aff2"
40+
GIT_REPOSITORY "https://github.com/gongweibao/brpc"
41+
GIT_TAG "7dc04defad1fd4173aae170c3fcbde131b65155a"
3342
PREFIX ${BRPC_SOURCES_DIR}
3443
UPDATE_COMMAND ""
3544
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
@@ -42,14 +51,16 @@ ExternalProject_Add(
4251
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
4352
-DCMAKE_PREFIX_PATH=${prefix_path}
4453
-DBRPC_WITH_GLOG=ON
54+
-DIOBUF_WITH_HUGE_BLOCK=ON
55+
-DBRPC_WITH_RDMA=${WITH_BRPC_RDMA}
4556
${EXTERNAL_OPTIONAL_ARGS}
4657
LIST_SEPARATOR |
4758
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${BRPC_INSTALL_DIR}
4859
-DCMAKE_INSTALL_LIBDIR:PATH=${BRPC_INSTALL_DIR}/lib
4960
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
5061
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
5162
)
52-
ADD_DEPENDENCIES(extern_brpc protobuf leveldb gflags glog gtest snappy)
63+
ADD_DEPENDENCIES(extern_brpc protobuf ssl crypto leveldb gflags glog gtest snappy)
5364
ADD_LIBRARY(brpc STATIC IMPORTED GLOBAL)
5465
SET_PROPERTY(TARGET brpc PROPERTY IMPORTED_LOCATION ${BRPC_LIBRARIES})
5566
ADD_DEPENDENCIES(brpc extern_brpc)

0 commit comments

Comments
 (0)