Skip to content

Commit f86429d

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into fix_slim_quant_bugs
test=develop
2 parents 5ab5687 + eb83abe commit f86429d

File tree

255 files changed

+11012
-1556
lines changed

Some content is hidden

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

255 files changed

+11012
-1556
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ option(WITH_DISTRIBUTE "Compile with distributed support" OFF)
6464
option(WITH_PSLIB "Compile with pslib support" OFF)
6565
option(WITH_CONTRIB "Compile the third-party contributation" OFF)
6666
option(REPLACE_ENFORCE_GLOG "Replace PADDLE_ENFORCE with glog/CHECK for better debug." OFF)
67+
# TODO(Superjomn) Remove WITH_ANAKIN option if not needed latter.
6768
option(WITH_ANAKIN "Compile with Anakin library" OFF)
6869
option(ANAKIN_BUILD_FAT_BIN "Build anakin cuda fat-bin lib for all device plantform, ignored when WITH_ANAKIN=OFF" OFF)
6970
option(ANAKIN_BUILD_CROSS_PLANTFORM "Build anakin lib for any nvidia device plantform. ignored when WITH_ANAKIN=OFF" ON)
@@ -190,7 +191,14 @@ include(configure) # add paddle env configuration
190191
if(WITH_GPU)
191192
include(cuda)
192193
include(tensorrt)
194+
include(anakin_subgraph)
193195
endif()
196+
197+
if(WITH_GPU AND NOT WIN32)
198+
message(STATUS "add dgc lib.")
199+
include(external/dgc)
200+
endif()
201+
194202
if(WITH_MKL OR WITH_MKLML)
195203
include(external/anakin)
196204
elseif()

cmake/anakin_subgraph.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
if(NOT WITH_GPU)
2+
return()
3+
endif()
4+
5+
set(ANAKIN_ROOT "/usr" CACHE PATH "ANAKIN ROOT")
6+
find_path(ANAKIN_INCLUDE_DIR anakin_config.h
7+
PATHS ${ANAKIN_ROOT} ${ANAKIN_ROOT}/include
8+
$ENV{ANAKIN_ROOT} $ENV{ANAKIN_ROOT}/include
9+
NO_DEFAULT_PATH
10+
)
11+
12+
find_library(ANAKIN_LIBRARY NAMES libanakin_saber_common.so libanakin.so
13+
PATHS ${ANAKIN_ROOT}
14+
$ENV{ANAKIN_ROOT} $ENV{ANAKIN_ROOT}/lib
15+
NO_DEFAULT_PATH
16+
DOC "Path to ANAKIN library.")
17+
18+
if(ANAKIN_INCLUDE_DIR AND ANAKIN_LIBRARY)
19+
if(WITH_DSO)
20+
set(ANAKIN_FOUND ON)
21+
endif(WITH_DSO)
22+
else()
23+
set(ANAKIN_FOUND OFF)
24+
endif()
25+
26+
if(ANAKIN_FOUND)
27+
message(STATUS "Current ANAKIN header is ${ANAKIN_INCLUDE_DIR}/anakin_config.h. ")
28+
include_directories(${ANAKIN_ROOT}/include)
29+
include_directories(${ANAKIN_ROOT}/include/saber)
30+
link_directories(${ANAKIN_ROOT})
31+
add_definitions(-DPADDLE_WITH_ANAKIN)
32+
endif()

cmake/external/dgc.cmake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2016 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+
15+
INCLUDE(ExternalProject)
16+
17+
SET(DGC_SOURCES_DIR "${THIRD_PARTY_PATH}/dgc")
18+
SET(DGC_INSTALL_DIR "${THIRD_PARTY_PATH}/install/dgc")
19+
SET(DGC_INCLUDE_DIR "${DGC_INSTALL_DIR}/include" CACHE PATH "dgc include directory." FORCE)
20+
SET(DGC_LIBRARIES "${DGC_INSTALL_DIR}/lib/libdgc.a" CACHE FILEPATH "dgc library." FORCE)
21+
INCLUDE_DIRECTORIES(${DGC_INCLUDE_DIR})
22+
23+
ExternalProject_Add(
24+
extern_dgc
25+
${EXTERNAL_PROJECT_LOG_ARGS}
26+
GIT_REPOSITORY "https://github.com/PaddlePaddle/Fleet"
27+
GIT_TAG "2d04dc3800cdd0601f1b65d547dabcc60b0cf9dc"
28+
SOURCE_DIR "${DGC_SOURCES_DIR}"
29+
CONFIGURE_COMMAND ""
30+
BUILD_COMMAND cd collective && make -j
31+
INSTALL_COMMAND mkdir -p ${DGC_INSTALL_DIR}/lib/ ${DGC_INCLUDE_DIR}/dgc
32+
&& cp ${DGC_SOURCES_DIR}/collective/build/lib/libdgc.a ${DGC_LIBRARIES}
33+
&& cp ${DGC_SOURCES_DIR}/collective/build/include/dgc.h ${DGC_INCLUDE_DIR}/dgc/
34+
BUILD_IN_SOURCE 1
35+
)
36+
37+
ADD_LIBRARY(dgc SHARED IMPORTED GLOBAL)
38+
SET_PROPERTY(TARGET dgc PROPERTY IMPORTED_LOCATION ${DGC_LIBRARIES})
39+
ADD_DEPENDENCIES(dgc extern_dgc)
40+
41+
LIST(APPEND external_project_dependencies dgc)
42+

cmake/external/ngraph.cmake

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,25 @@ SET(NGRAPH_TBB_LIB ${NGRAPH_LIB_DIR}/${NGRAPH_TBB_LIB_NAME})
5757
ExternalProject_Add(
5858
${NGRAPH_PROJECT}
5959
${EXTERNAL_PROJECT_LOG_ARGS}
60-
DEPENDS ${MKLDNN_PROJECT} ${MKLML_PROJECT}
61-
GIT_REPOSITORY ${NGRAPH_GIT_REPO}
62-
GIT_TAG ${NGRAPH_GIT_TAG}
63-
PREFIX ${NGRAPH_SOURCES_DIR}
64-
UPDATE_COMMAND ""
65-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${NGRAPH_INSTALL_DIR}
66-
CMAKE_ARGS -DNGRAPH_UNIT_TEST_ENABLE=FALSE
67-
CMAKE_ARGS -DNGRAPH_TOOLS_ENABLE=FALSE
68-
CMAKE_ARGS -DNGRAPH_INTERPRETER_ENABLE=FALSE
69-
CMAKE_ARGS -DNGRAPH_DEX_ONLY=TRUE
70-
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
71-
CMAKE_ARGS -DMKLDNN_INCLUDE_DIR=${MKLDNN_INC_DIR}
72-
CMAKE_ARGS -DMKLDNN_LIB_DIR=${MKLDNN_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}
73-
CMAKE_ARGS -DMKLML_LIB_DIR=${MKLML_INSTALL_DIR}/lib
60+
DEPENDS ${MKLDNN_PROJECT} ${MKLML_PROJECT}
61+
GIT_REPOSITORY ${NGRAPH_GIT_REPO}
62+
GIT_TAG ${NGRAPH_GIT_TAG}
63+
PREFIX ${NGRAPH_SOURCES_DIR}
64+
UPDATE_COMMAND ""
65+
CMAKE_GENERATOR ${CMAKE_GENERATOR}
66+
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
67+
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
68+
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
69+
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
70+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${NGRAPH_INSTALL_DIR}
71+
CMAKE_ARGS -DNGRAPH_UNIT_TEST_ENABLE=FALSE
72+
CMAKE_ARGS -DNGRAPH_TOOLS_ENABLE=FALSE
73+
CMAKE_ARGS -DNGRAPH_INTERPRETER_ENABLE=FALSE
74+
CMAKE_ARGS -DNGRAPH_DEX_ONLY=TRUE
75+
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
76+
CMAKE_ARGS -DMKLDNN_INCLUDE_DIR=${MKLDNN_INC_DIR}
77+
CMAKE_ARGS -DMKLDNN_LIB_DIR=${MKLDNN_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}
78+
CMAKE_ARGS -DMKLML_LIB_DIR=${MKLML_INSTALL_DIR}/lib
7479
)
7580

7681
add_dependencies(ngraph ${NGRAPH_PROJECT})

cmake/inference_lib.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ elseif (NOT CBLAS_FOUND OR WIN32)
131131
)
132132
endif ()
133133

134+
if (WITH_GPU AND NOT WIN32)
135+
set(dgc_dir "${FLUID_INSTALL_DIR}/third_party/install/dgc")
136+
copy(dgc_lib
137+
SRCS ${DGC_INSTALL_DIR}/lib ${DGC_INSTALL_DIR}/include
138+
DSTS ${dgc_dir} ${dgc_dir}
139+
DEPS dgc)
140+
endif()
141+
142+
134143
if (WITH_MKLDNN)
135144
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/mkldnn")
136145
copy(mkldnn_lib

cmake/operators.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function(op_library TARGET)
110110
# Define operators that don't need pybind here.
111111
foreach(manual_pybind_op "compare_op" "logical_op" "nccl_op"
112112
"tensor_array_read_write_op" "tensorrt_engine_op" "conv_fusion_op"
113-
"fusion_transpose_flatten_concat_op" "fusion_conv_inception_op" "sync_batch_norm_op")
113+
"fusion_transpose_flatten_concat_op" "fusion_conv_inception_op" "sync_batch_norm_op" "dgc_op")
114114
if ("${TARGET}" STREQUAL "${manual_pybind_op}")
115115
set(pybind_flag 1)
116116
endif()

cmake/tensorrt.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ if(TENSORRT_FOUND)
3333
message(STATUS "Current TensorRT header is ${TENSORRT_INCLUDE_DIR}/NvInfer.h. "
3434
"Current TensorRT version is v${TENSORRT_MAJOR_VERSION}. ")
3535
include_directories(${TENSORRT_INCLUDE_DIR})
36+
link_directories(${TENSORRT_LIBRARY})
3637
add_definitions(-DPADDLE_WITH_TENSORRT)
3738
endif()

paddle/fluid/API.spec

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ paddle.fluid.layers.mean (ArgSpec(args=['x', 'name'], varargs=None, keywords=Non
211211
paddle.fluid.layers.mul (ArgSpec(args=['x', 'y', 'x_num_col_dims', 'y_num_col_dims', 'name'], varargs=None, keywords=None, defaults=(1, 1, None)), ('document', 'ccd37fa6b53f074adbfb732d738c4c2d'))
212212
paddle.fluid.layers.sigmoid_cross_entropy_with_logits (ArgSpec(args=['x', 'label', 'ignore_index', 'name', 'normalize'], varargs=None, keywords=None, defaults=(-100, None, False)), ('document', '180c284317ea45ef89a460d8d79c0b72'))
213213
paddle.fluid.layers.maxout (ArgSpec(args=['x', 'groups', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '891870d069a6aea746d34cc53b61690c'))
214-
paddle.fluid.layers.space_to_depth (ArgSpec(args=['x', 'blocksize', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '5f207ae10589ebe38a63575ef6ff8e1e'))
214+
paddle.fluid.layers.space_to_depth (ArgSpec(args=['x', 'blocksize', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', 'a9221eaef53884a00654e028551b78e2'))
215215
paddle.fluid.layers.affine_grid (ArgSpec(args=['theta', 'out_shape', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '51def402b8910e163cbace9d0c0526ed'))
216216
paddle.fluid.layers.sequence_reverse (ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '77a6d80aa5551ca70324fc975c44507f'))
217217
paddle.fluid.layers.affine_channel (ArgSpec(args=['x', 'scale', 'bias', 'data_layout', 'name', 'act'], varargs=None, keywords=None, defaults=(None, None, 'NCHW', None, None)), ('document', 'ab84fdc6dc60f3ad9aa397e6007e3bf9'))
@@ -483,6 +483,11 @@ paddle.fluid.optimizer.LarsMomentumOptimizer.apply_gradients (ArgSpec(args=['sel
483483
paddle.fluid.optimizer.LarsMomentumOptimizer.backward (ArgSpec(args=['self', 'loss', 'startup_program', 'parameter_list', 'no_grad_set', 'callbacks'], varargs=None, keywords=None, defaults=(None, None, None, None)), ('document', 'ba3a113d0229ff7bc9d39bda0a6d947f'))
484484
paddle.fluid.optimizer.LarsMomentumOptimizer.get_opti_var_name_list (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
485485
paddle.fluid.optimizer.LarsMomentumOptimizer.minimize (ArgSpec(args=['self', 'loss', 'startup_program', 'parameter_list', 'no_grad_set'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', '35fd5d3330c97903528c7e0dacc7f6ea'))
486+
paddle.fluid.optimizer.DGCMomentumOptimizer.__init__ (ArgSpec(args=['self', 'learning_rate', 'momentum', 'rampup_begin_step', 'rampup_step', 'sparsity', 'use_nesterov', 'local_grad_clip_norm', 'num_trainers', 'regularization', 'name'], varargs=None, keywords=None, defaults=(1, [0.999], False, None, None, None, None)), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
487+
paddle.fluid.optimizer.DGCMomentumOptimizer.apply_gradients (ArgSpec(args=['self', 'params_grads'], varargs=None, keywords=None, defaults=None), ('document', 'bfe7305918552aaecfdaa22411dbe871'))
488+
paddle.fluid.optimizer.DGCMomentumOptimizer.backward (ArgSpec(args=['self', 'loss', 'startup_program', 'parameter_list', 'no_grad_set', 'callbacks'], varargs=None, keywords=None, defaults=(None, None, None, None)), ('document', 'ba3a113d0229ff7bc9d39bda0a6d947f'))
489+
paddle.fluid.optimizer.DGCMomentumOptimizer.get_opti_var_name_list (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
490+
paddle.fluid.optimizer.DGCMomentumOptimizer.minimize (ArgSpec(args=['self', 'loss', 'startup_program', 'parameter_list', 'no_grad_set'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', '35fd5d3330c97903528c7e0dacc7f6ea'))
486491
paddle.fluid.backward.append_backward (ArgSpec(args=['loss', 'parameter_list', 'no_grad_set', 'callbacks'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', '1a79bd7d10ae54ca763ec81bca36ba24'))
487492
paddle.fluid.regularizer.L1DecayRegularizer.__init__ (ArgSpec(args=['self', 'regularization_coeff'], varargs=None, keywords=None, defaults=(0.0,)), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
488493
paddle.fluid.regularizer.L2DecayRegularizer.__init__ (ArgSpec(args=['self', 'regularization_coeff'], varargs=None, keywords=None, defaults=(0.0,)), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
@@ -520,6 +525,7 @@ paddle.fluid.unique_name.guard (ArgSpec(args=['new_generator'], varargs=None, ke
520525
paddle.fluid.recordio_writer.convert_reader_to_recordio_file (ArgSpec(args=['filename', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None)), ('document', '65c7523e86f0c50bb729b01667f36310'))
521526
paddle.fluid.recordio_writer.convert_reader_to_recordio_files (ArgSpec(args=['filename', 'batch_per_file', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None)), ('document', 'bc643f0f5f1b9db57ff0d8a57d379bd7'))
522527
paddle.fluid.Scope Scope() -> paddle.fluid.core._Scope
528+
paddle.fluid.install_check.run_check (ArgSpec(args=[], varargs=None, keywords=None, defaults=None), ('document', '66b7c84a17ed32fec2df9628367be2b9'))
523529
paddle.reader.cache (ArgSpec(args=['reader'], varargs=None, keywords=None, defaults=None), ('document', '1676886070eb607cb608f7ba47be0d3c'))
524530
paddle.reader.map_readers (ArgSpec(args=['func'], varargs='readers', keywords=None, defaults=None), ('document', '77cbadb09df588e21e5cc0819b69c87d'))
525531
paddle.reader.buffered (ArgSpec(args=['reader', 'size'], varargs=None, keywords=None, defaults=None), ('document', '0d6186f109feceb99f60ec50a0a624cb'))

paddle/fluid/framework/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cc_library(lod_tensor SRCS lod_tensor.cc DEPS ddim place tensor framework_proto
6363
cc_test(lod_tensor_test SRCS lod_tensor_test.cc DEPS lod_tensor memory)
6464
nv_test(lod_tensor_gpu_test SRCS lod_tensor_test.cu DEPS lod_tensor)
6565

66-
cc_library(garbage_collector SRCS garbage_collector.cc DEPS device_context memory)
66+
cc_library(garbage_collector SRCS garbage_collector.cc DEPS device_context memory gflags glog)
6767

6868
cc_library(reader SRCS reader.cc DEPS lod_tensor ddim)
6969
cc_test(reader_test SRCS reader_test.cc DEPS reader)
@@ -164,6 +164,8 @@ else()
164164
set(NGRAPH_EXE_DEPS)
165165
endif()
166166

167+
cc_library(executor_gc_helper SRCS executor_gc_helper.cc DEPS scope proto_desc operator garbage_collector)
168+
167169
if(WITH_DISTRIBUTE)
168170
cc_library(executor SRCS executor.cc DEPS op_registry device_context scope framework_proto glog
169171
lod_rank_table feed_fetch_method sendrecvop_rpc ${GLOB_DISTRIBUTE_DEPS} graph_to_program_pass variable_helper ${NGRAPH_EXE_DEPS})
@@ -174,7 +176,7 @@ else()
174176
cc_test(test_naive_executor SRCS naive_executor_test.cc DEPS naive_executor elementwise_add_op)
175177
endif()
176178

177-
target_link_libraries(executor garbage_collector while_op_helper)
179+
target_link_libraries(executor while_op_helper executor_gc_helper)
178180

179181
cc_library(parallel_executor SRCS parallel_executor.cc DEPS
180182
threaded_ssa_graph_executor scope_buffered_ssa_graph_executor parallel_ssa_graph_executor
@@ -194,6 +196,7 @@ cc_test(prune_test SRCS prune_test.cc DEPS op_info prune recurrent_op device_con
194196
cc_test(var_type_inference_test SRCS var_type_inference_test.cc DEPS op_registry
195197
proto_desc)
196198
cc_test(inplace_op_inference_test SRCS inplace_op_inference_test.cc DEPS op_registry proto_desc op_info memory_optimize_helper)
199+
197200
cc_library(selected_rows SRCS selected_rows.cc DEPS tensor)
198201
cc_test(selected_rows_test SRCS selected_rows_test.cc DEPS selected_rows)
199202

paddle/fluid/framework/details/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif()
2323

2424
if(WITH_GPU)
2525
nv_library(all_reduce_op_handle SRCS all_reduce_op_handle.cc DEPS op_handle_base scope lod_tensor ddim memory
26-
dynload_cuda variable_visitor)
26+
dynload_cuda variable_visitor dgc)
2727
nv_library(fused_all_reduce_op_handle SRCS fused_all_reduce_op_handle.cc DEPS op_handle_base scope lod_tensor ddim memory
2828
dynload_cuda variable_visitor)
2929
if(WITH_DISTRIBUTE)

0 commit comments

Comments
 (0)