Skip to content

Commit 6416eee

Browse files
author
Yibing Liu
committed
Merge branch 'develop' of upstream into profiling_tool
2 parents ea0280b + 8814bec commit 6416eee

File tree

21 files changed

+291
-56
lines changed

21 files changed

+291
-56
lines changed

cmake/external/mkldnn.cmake

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ ExternalProject_Add(
6363
-DMKLROOT:PATH=${MKLML_ROOT}
6464
)
6565

66-
ADD_LIBRARY(mkldnn SHARED IMPORTED GLOBAL)
67-
SET_PROPERTY(TARGET mkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB})
68-
ADD_DEPENDENCIES(mkldnn ${MKLDNN_PROJECT})
66+
ADD_LIBRARY(shared_mkldnn SHARED IMPORTED GLOBAL)
67+
SET_PROPERTY(TARGET shared_mkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB})
68+
ADD_DEPENDENCIES(shared_mkldnn ${MKLDNN_PROJECT})
6969
MESSAGE(STATUS "MKLDNN library: ${MKLDNN_LIB}")
7070
add_definitions(-DPADDLE_WITH_MKLDNN)
71-
LIST(APPEND external_project_dependencies mkldnn)
71+
LIST(APPEND external_project_dependencies shared_mkldnn)
72+
73+
# generate a static dummy target to track mkldnn dependencies
74+
# for cc_library(xxx SRCS xxx.c DEPS mkldnn)
75+
SET(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/mkldnn_dummy.c)
76+
FILE(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";")
77+
ADD_LIBRARY(mkldnn STATIC ${dummyfile})
78+
TARGET_LINK_LIBRARIES(mkldnn ${MKLDNN_LIB} ${MKLML_LIB} ${MKLML_IOMP_LIB})
79+
ADD_DEPENDENCIES(mkldnn ${MKLDNN_PROJECT})

doc/design/ci_build_whl.png

280 KB
Loading

doc/design/releasing_process.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ PaddlePaddle每次发新的版本,遵循以下流程:
77
1.`develop`分支派生出新的分支,分支名为`release/版本号`。例如,`release/0.10.0`
88
1. 将新分支的版本打上tag,tag为`版本号rc.Patch号`。第一个tag为`0.10.0rc1`,第二个为`0.10.0rc2`,依次类推。
99
1. 对这个版本的提交,做如下几个操作:
10+
* 使用Regression Test List作为检查列表,测试本次release的正确性。
11+
* 如果失败,记录下所有失败的例子,在这个`release/版本号`分支中,修复所有bug后,Patch号加一,到第二步
1012
* 修改`python/setup.py.in`中的版本信息,并将`istaged`字段设为`True`。
11-
* 编译这个版本的Docker发行镜像,发布到dockerhub。如果失败,修复Docker编译镜像问题,Patch号加一,返回第二步
12-
* 编译这个版本的Ubuntu Deb包。如果失败,修复Ubuntu Deb包编译问题,Patch号加一,返回第二步。
13-
* 使用Regression Test List作为检查列表,测试Docker镜像/ubuntu安装包的功能正确性
14-
* 如果失败,记录下所有失败的例子,在这个`release/版本号`分支中,修复所有bug后,Patch号加一,返回第二步
1513
* 编译这个版本的python wheel包,并发布到pypi。
1614
* 由于pypi.python.org目前遵循[严格的命名规范PEP 513](https://www.python.org/dev/peps/pep-0513),在使用twine上传之前,需要重命名wheel包中platform相关的后缀,比如将`linux_x86_64`修改成`manylinux1_x86_64`。
1715
* pypi上的package名称为paddlepaddle和paddlepaddle_gpu,如果要上传GPU版本的包,需要修改build/python/setup.py中,name: "paddlepaddle_gpu"并重新打包wheel包:`python setup.py bdist_wheel`。
@@ -21,8 +19,8 @@ PaddlePaddle每次发新的版本,遵循以下流程:
2119
pip install twine
2220
twine upload dist/[package to upload]
2321
```
22+
* 编译这个版本的Docker发行镜像,发布到dockerhub。如果失败,修复Docker编译镜像问题,Patch号加一,返回第二步
2423
1. 第三步完成后,将`release/版本号`分支合入master分支,并删除`release/版本号`分支。将master分支的合入commit打上tag,tag为`版本号`。同时再将`master`分支合入`develop`分支。最后删除`release/版本号`分支。
25-
1. 编译master分支的Docker发行镜像,发布到dockerhub。编译ubuntu的deb包,发布到github release页面
2624
1. 协同完成Release Note的书写
2725

2826

@@ -31,6 +29,30 @@ PaddlePaddle每次发新的版本,遵循以下流程:
3129
* `release/版本号`分支一旦建立,一般不允许再从`develop`分支合入`release/版本号`。这样保证`release/版本号`分支功能的封闭,方便测试人员测试PaddlePaddle的行为。
3230
*`release/版本号`分支存在的时候,如果有bugfix的行为,需要将bugfix的分支同时merge到`master`, `develop``release/版本号`这三个分支。
3331

32+
## 发布wheel包到pypi
33+
34+
使用[PaddlePaddle CI](https://paddleci.ngrok.io/project.html?projectId=Manylinux1&tab=projectOverview)
35+
完成自动化二进制编译,参考下图,选择需要发布的版本(通常包含一个CPU版本和一个GPU版本),点击"run"右侧的"..."按钮,可以
36+
弹出下面的选择框,在第二个tab (Changes)里选择需要发布的分支,这里选择0.11.0,然后点击"Run Build"按钮。等待编译完成后
37+
可以在此页面的"Artifacts"下拉框中找到生成的3个二进制文件,分别对应CAPI,`cp27m``cp27mu`的版本。然后按照上述的方法
38+
使用`twine`工具上传即可。
39+
40+
<img src="ci_build_whl.png">
41+
42+
* 注:CI环境使用 https://github.com/PaddlePaddle/buildtools 这里的DockerImage作为编译环境以支持更多的Linux
43+
发型版,如果需要手动编译,也可以使用这些镜像。这些镜像也可以从 https://hub.docker.com/r/paddlepaddle/paddle_manylinux_devel/tags/ 下载得到。
44+
* pypi不支持覆盖上传,所以一个版本号的wheel包发布之后,不可以更改。下一个wheel包需要更新版本号才可以上传。
45+
46+
## 发布Docker镜像
47+
48+
上述PaddlePaddle CI编译wheel完成后会自动将Docker镜像push到DockerHub,所以,发布Docker镜像只需要对自动push的镜像打上
49+
版本号对应的tag即可:
50+
51+
1. 进入 https://hub.docker.com/r/paddlepaddle/paddle/tags/ 查看latest tag的更新时间是否在上述编译wheel包完成后是否最新。
52+
1. 执行 `docker pull paddlepaddle/paddle:[latest tag]`,latest tag可以是latest或latest-gpu等。
53+
1. 执行 `docker tag paddlepaddle/paddle:[latest tag] paddlepaddle/paddle:[version]`
54+
1. 执行 `docker push paddlepaddle/paddle:[version]`
55+
3456
## PaddlePaddle 分支规范
3557

3658
PaddlePaddle开发过程使用[git-flow](http://nvie.com/posts/a-successful-git-branching-model/)分支规范,并适应github的特性做了一些区别。

paddle/framework/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ device_context)
4141
cc_library(op_proto_maker SRCS op_proto_maker.cc DEPS framework_proto attribute)
4242
cc_test(op_proto_maker_test SRCS op_proto_maker_test.cc DEPS op_proto_maker)
4343
cc_library(op_info SRCS op_info.cc DEPS attribute framework_proto)
44-
cc_library(shape_inference SRCS shape_inference.cc DEPS ddim attribute)
44+
cc_library(shape_inference SRCS shape_inference.cc DEPS ddim attribute device_context)
4545
cc_library(operator SRCS operator.cc DEPS op_info device_context tensor scope glog
4646
shape_inference data_transform)
4747
cc_test(operator_test SRCS operator_test.cc DEPS operator op_registry init)

paddle/framework/executor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void Executor::Run(const ProgramDesc& pdesc, Scope* scope, int block_id,
111111

112112
for (auto& op_desc : block.AllOps()) {
113113
auto op = paddle::framework::OpRegistry::CreateOp(*op_desc);
114-
VLOG(3) << op->DebugString();
114+
VLOG(3) << op->DebugStringEx(local_scope);
115115
op->Run(*local_scope, place_);
116116
if (FLAGS_check_nan_inf) {
117117
for (auto& vname : op->OutputVars(true)) {

paddle/framework/operator.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ void UseALL() {
7373
UseCUDNN();
7474
}
7575

76+
static DDim GetDims(const Scope& scope, const std::string& name) {
77+
Variable* var = scope.FindVar(name);
78+
if (var->IsType<LoDTensor>()) {
79+
return var->Get<LoDTensor>().dims();
80+
} else if (var->IsType<SelectedRows>()) {
81+
return var->Get<SelectedRows>().GetCompleteDims();
82+
} else {
83+
return DDim({-1});
84+
}
85+
}
86+
7687
std::string OperatorBase::Input(const std::string& name) const {
7788
auto& ins = Inputs(name);
7889
PADDLE_ENFORCE_LE(ins.size(), 1UL,
@@ -105,14 +116,17 @@ const std::vector<std::string>& OperatorBase::Outputs(
105116
return it->second;
106117
}
107118

108-
std::string OperatorBase::DebugString() const {
119+
std::string OperatorBase::DebugStringEx(const Scope* scope) const {
109120
std::stringstream ss;
110121
ss << "Op(" << type_ << "), inputs:{";
111122
for (auto it = inputs_.begin(); it != inputs_.end();) {
112123
auto& input = *it;
113124
ss << input.first << "[";
114125
for (size_t i = 0; i < input.second.size(); ++i) {
115126
ss << input.second[i];
127+
if (scope) {
128+
ss << "(" << GetDims(*scope, input.second[i]) << ")";
129+
}
116130
if (i != input.second.size() - 1) {
117131
ss << ", ";
118132
}
@@ -129,6 +143,9 @@ std::string OperatorBase::DebugString() const {
129143
ss << output.first << "[";
130144
for (size_t i = 0; i < output.second.size(); ++i) {
131145
ss << output.second[i];
146+
if (scope) {
147+
ss << "(" << GetDims(*scope, output.second[i]) << ")";
148+
}
132149
if (i != output.second.size() - 1) {
133150
ss << ", ";
134151
}

paddle/framework/operator.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ class OperatorBase {
108108
return boost::get<T>(attrs_.at(name));
109109
}
110110

111-
virtual std::string DebugString() const;
111+
/// if scope is not null, also show dimensions of arguments
112+
virtual std::string DebugStringEx(const Scope* scope) const;
113+
114+
std::string DebugString() const { return DebugStringEx(nullptr); }
112115

113116
/// Net will call this function to Run an op.
114117
virtual void Run(const Scope& scope, const platform::Place& place) const = 0;

paddle/inference/inference.cc

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,16 @@ void InferenceEngine::LoadInferenceModel(
3838
LOG(INFO) << "program_desc_str's size: " << program_desc_str.size();
3939
// PicklingTools cannot parse the vector of strings correctly.
4040
#else
41-
// program_desc_str
42-
// the inference.model is stored by following python codes:
43-
// inference_program = fluid.io.get_inference_program(predict)
44-
// model_filename = "recognize_digits_mlp.inference.model/inference.model"
45-
// with open(model_filename, "w") as f:
46-
// program_str = inference_program.desc.serialize_to_string()
47-
// f.write(struct.pack('q', len(program_str)))
48-
// f.write(program_str)
49-
std::string model_filename = dirname + "/inference.model";
41+
std::string model_filename = dirname + "/__model__.dat";
5042
LOG(INFO) << "loading model from " << model_filename;
51-
std::ifstream fs(model_filename, std::ios_base::binary);
52-
int64_t size = 0;
53-
fs.read(reinterpret_cast<char*>(&size), sizeof(int64_t));
54-
LOG(INFO) << "program_desc_str's size: " << size;
43+
std::ifstream inputfs(model_filename, std::ios::in | std::ios::binary);
5544
std::string program_desc_str;
56-
program_desc_str.resize(size);
57-
fs.read(&program_desc_str[0], size);
45+
inputfs.seekg(0, std::ios::end);
46+
program_desc_str.resize(inputfs.tellg());
47+
inputfs.seekg(0, std::ios::beg);
48+
LOG(INFO) << "program_desc_str's size: " << program_desc_str.size();
49+
inputfs.read(&program_desc_str[0], program_desc_str.size());
50+
inputfs.close();
5851
#endif
5952
program_ = new framework::ProgramDesc(program_desc_str);
6053
GenerateLoadProgram(dirname);

paddle/operators/net_op.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ void NetOp::CompleteAddOp(bool calc) {
5656
std::copy(output_set.begin(), output_set.end(), std::back_inserter(outputs));
5757
}
5858

59-
std::string NetOp::DebugString() const {
59+
std::string NetOp::DebugStringEx(const framework::Scope* scope) const {
6060
std::ostringstream os;
61-
os << OperatorBase::DebugString() << std::endl;
61+
os << OperatorBase::DebugStringEx(scope) << std::endl;
6262
for (auto& op : ops_) {
63-
std::istringstream is(op->DebugString());
63+
std::istringstream is(op->DebugStringEx(scope));
6464
for (std::string line; std::getline(is, line);) {
6565
os << " " << line << std::endl;
6666
}

paddle/operators/net_op.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class NetOp : public framework::OperatorBase {
106106

107107
void CompleteAddOp(bool calculate = true);
108108

109-
std::string DebugString() const override;
109+
std::string DebugStringEx(
110+
const framework::Scope* scope = nullptr) const override;
110111

111112
bool IsNetOp() const override;
112113
std::vector<std::string> OutputVars(bool has_intermediate) const override;

0 commit comments

Comments
 (0)