Skip to content

Commit 6a630f2

Browse files
committed
Merge branch 'develop' into crf
2 parents 427644b + 200a02e commit 6a630f2

File tree

106 files changed

+5038
-1508
lines changed

Some content is hidden

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

106 files changed

+5038
-1508
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ include(external/warpctc) # download, build, install warpctc
127127
include(external/any) # download libn::any
128128
include(external/eigen) # download eigen3
129129
include(external/pybind11) # download pybind11
130+
include(external/nccl)
130131

131132
include(cudnn) # set cudnn libraries, must before configure
132133
include(configure) # add paddle env configuration
@@ -159,7 +160,7 @@ set(EXTERNAL_LIBS
159160
if(WITH_GPU)
160161
list(APPEND EXTERNAL_LIBS ${CUDA_LIBRARIES} ${CUDA_rt_LIBRARY})
161162
if(NOT WITH_DSO)
162-
list(APPEND EXTERNAL_LIBS ${CUDNN_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY})
163+
list(APPEND EXTERNAL_LIBS ${CUDNN_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY} ${NCCL_LIBRARY})
163164
endif(NOT WITH_DSO)
164165
endif(WITH_GPU)
165166

cmake/configure.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ else()
6262
FIND_PACKAGE(CUDA REQUIRED)
6363

6464
if(${CUDA_VERSION_MAJOR} VERSION_LESS 7)
65-
message(FATAL_ERROR "Paddle need CUDA >= 7.0 to compile")
65+
message(FATAL_ERROR "Paddle needs CUDA >= 7.0 to compile")
6666
endif()
6767

6868
if(NOT CUDNN_FOUND)
69-
message(FATAL_ERROR "Paddle need cudnn to compile")
69+
message(FATAL_ERROR "Paddle needs cudnn to compile")
7070
endif()
7171

7272
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${SIMD_FLAG}")

cmake/external/nccl.cmake

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
INCLUDE(ExternalProject)
2+
3+
SET(NCCL_SOURCE_DIR ${THIRD_PARTY_PATH}/nccl)
4+
5+
INCLUDE_DIRECTORIES(${NCCL_SOURCE_DIR}/src/extern_nccl/src)
6+
7+
8+
if(WITH_DSO)
9+
# If we use DSO, we do not build nccl, just download the dependencies
10+
set(NCCL_BUILD_COMMAND "")
11+
set(NCCL_INSTALL_COMMAND "")
12+
set(NCCL_INSTALL_DIR "")
13+
else()
14+
# otherwise, we build nccl and link it.
15+
set(NCCL_BUILD_COMMAND "make -j 8")
16+
set(NCCL_INSTALL_COMMAND "make install")
17+
SET(NCCL_INSTALL_DIR ${THIRD_PARTY_PATH}/install/nccl)
18+
endif()
19+
20+
ExternalProject_Add(
21+
extern_nccl
22+
${EXTERNAL_PROJECT_LOG_ARGS}
23+
GIT_REPOSITORY "https://github.com/NVIDIA/nccl.git"
24+
GIT_TAG "v1.3.4-1"
25+
PREFIX "${NCCL_SOURCE_DIR}"
26+
UPDATE_COMMAND ""
27+
CONFIGURE_COMMAND ""
28+
BUILD_COMMAND "${NCCL_BUILD_COMMAND}"
29+
INSTALL_COMMAND "${NCCL_INSTALL_COMMAND}"
30+
INSTALL_DIR "${NCCL_INSTALL_DIR}"
31+
TEST_COMMAND ""
32+
)
33+
34+
if (WITH_DSO)
35+
if (${CMAKE_VERSION} VERSION_LESS "3.3.0")
36+
set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/lib_any_dummy.c)
37+
file(WRITE ${dummyfile} "const char * dummy_any = \"${dummyfile}\";")
38+
add_library(nccl STATIC ${dummyfile})
39+
else()
40+
add_library(nccl INTERFACE)
41+
endif()
42+
else()
43+
ADD_LIBRARY(nccl STATIC IMPORTED GLOBAL)
44+
SET_PROPERTY(TARGET nccl PROPERTY IMPORTED_LOCATION
45+
${NCCL_INSTALL_DIR}/lib/libnccl.a)
46+
endif()
47+
48+
add_dependencies(nccl extern_nccl)
49+
50+
LIST(APPEND external_project_dependencies nccl)

doc/faq/local/index_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ decoder_inputs = paddle.layer.fc(
174174
1. 两者都是对梯度的截断,但截断时机不同,前者在 :code:`optimzier` 更新网络参数时应用;后者在激活函数反向计算时被调用;
175175
2. 截断对象不同:前者截断可学习参数的梯度,后者截断回传给前层的梯度;
176176

177-
除此之外,还可以通过减小学习律或者对数据进行归一化处理来解决这类问题
177+
除此之外,还可以通过减小学习率或者对数据进行归一化处理来解决这类问题
178178

179179
5. 如何调用 infer 接口输出多个layer的预测结果
180180
-----------------------------------------------

paddle/framework/op_info.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,8 @@ class OpInfoMap {
8787
}
8888
}
8989

90-
template <typename Callback>
91-
void IterAllInfo(Callback callback) {
92-
for (auto& it : map_) {
93-
callback(it.first, it.second);
94-
}
90+
const std::unordered_map<std::string, const OpInfo>& map() const {
91+
return map_;
9592
}
9693

9794
private:

paddle/framework/var_desc.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ limitations under the License. */
1818
namespace paddle {
1919
namespace framework {
2020

21+
VarDesc::VarType VarDescBind::GetType() const { return desc_.type(); }
22+
23+
void VarDescBind::SetType(VarDesc::VarType type) { desc_.set_type(type); }
24+
2125
void VarDescBind::SetShape(const std::vector<int64_t> &dims) {
2226
VectorToRepeated(dims, mutable_tensor_desc()->mutable_dims());
2327
}

paddle/framework/var_desc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ class VarDescBind {
7575

7676
int32_t GetLodLevel() const;
7777

78-
VarDesc::VarType GetType() const { return desc_.type(); }
78+
VarDesc::VarType GetType() const;
7979

80-
void SetType(VarDesc::VarType type) { desc_.set_type(type); }
80+
void SetType(VarDesc::VarType type);
8181

8282
bool Persistable() const { return desc_.persistable(); }
8383

paddle/gserver/activations/MKLDNNActivation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void MKLDNNEltwiseActivation::resetFwd(Argument& act) {
126126
copyInVal_ = nullptr;
127127
if (act.grad && algo == algorithm::eltwise_tanh) {
128128
// tanh need save src input for backward
129-
inVal_ = MKLDNNMatrix::create(nullptr, val_->getPrimitiveDesc());
129+
inVal_ = MKLDNNMatrix::create(val_->getPrimitiveDesc());
130130
copyInVal_ = std::make_shared<mkldnn::reorder>(*val_, *inVal_);
131131
CHECK(copyInVal_) << "should not be emptry";
132132
pipelineFwd_.push_back(*copyInVal_);
@@ -145,7 +145,7 @@ void MKLDNNEltwiseActivation::resetBwd(Argument& act) {
145145
algorithm algo = getAlgo(this->getName());
146146
float alpha = getBwdAlpha();
147147
float beta = getBeta();
148-
grad_ = MKLDNNMatrix::create(act.grad, val_->getPrimitiveDesc());
148+
grad_ = MKLDNNMatrix::create(val_->getPrimitiveDesc(), act.grad);
149149
auto eng = CPUEngine::Instance().getEngine();
150150
auto bwdDesc = eltwise_bwd::desc(
151151
algo, grad_->getMemoryDesc(), val_->getMemoryDesc(), alpha, beta);
@@ -230,7 +230,7 @@ void MKLDNNActivation::resetFwd(Argument& act) {
230230
int ic = cnt_ / bs / ih / iw;
231231
CHECK_EQ(cnt_, (size_t)bs * ic * ih * iw);
232232
val_ = MKLDNNMatrix::create(
233-
act.value, {bs, ic, ih, iw}, mkldnn::memory::format::nchw, *engine_);
233+
{bs, ic, ih, iw}, mkldnn::memory::format::nchw, *engine_, act.value);
234234
CHECK(val_);
235235
val_->downSpatial();
236236
}

paddle/gserver/layers/MKLDNNBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ namespace paddle {
2121
typedef enum {
2222
MKLDNN_BASE = 1, // basical info of MKLDNN
2323
MKLDNN_TESTS = 1, // gtest info of MKLDNN
24-
MKLDNN_SIZES = 2, // size info of MKLDNN
25-
MKLDNN_FMTS = 3, // format info of MKLDNN
24+
MKLDNN_FMTS = 2, // format info of MKLDNN
25+
MKLDNN_SIZES = 3, // size info of MKLDNN
2626
MKLDNN_ALL = 4, // show all info of MKLDNN
2727
} MKLDNN_LOG_LEVEL;
2828

0 commit comments

Comments
 (0)