Skip to content

Commit 2bed961

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/paddle into fix-H0-GRUOp
2 parents b103072 + f07a226 commit 2bed961

File tree

65 files changed

+3140
-151
lines changed

Some content is hidden

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

65 files changed

+3140
-151
lines changed

doc/api/v2/config/layer.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ maxout
8282
.. autoclass:: paddle.v2.layer.maxout
8383
:noindex:
8484

85+
roi_pool
86+
--------
87+
.. autoclass:: paddle.v2.layer.roi_pool
88+
:noindex:
89+
8590
Norm Layer
8691
==========
8792

paddle/framework/scope.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,23 @@ void Scope::DeleteScope(Scope* scope) {
9898
delete scope;
9999
}
100100

101+
void Scope::Rename(const std::string& origin_name,
102+
const std::string& new_name) const {
103+
auto origin_it = vars_.find(origin_name);
104+
PADDLE_ENFORCE(origin_it != vars_.end(),
105+
"Cannot find original variable with name %s", origin_name);
106+
auto new_it = vars_.find(new_name);
107+
PADDLE_ENFORCE(new_it == vars_.end(),
108+
"The variable with name %s is already in the scope", new_name);
109+
vars_[new_name] = origin_it->second;
110+
vars_.erase(origin_it);
111+
}
112+
113+
std::string Scope::Rename(const std::string& origin_name) const {
114+
auto var_name = string::Sprintf("%p.%d", this, vars_.size());
115+
Rename(origin_name, var_name);
116+
return var_name;
117+
}
118+
101119
} // namespace framework
102120
} // namespace paddle

paddle/framework/scope.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,18 @@ class Scope {
6868
// enumerate all the variables current contains.
6969
std::vector<std::string> GetAllNames(bool recursive = false) const;
7070

71+
// Rename variable to a new name
72+
void Rename(const std::string& origin_name,
73+
const std::string& new_name) const;
74+
75+
// Rename variable to a new name and return the new name
76+
std::string Rename(const std::string& origin_name) const;
77+
7178
private:
7279
// Call Scope::NewScope for a sub-scope.
7380
explicit Scope(Scope const* parent) : parent_(parent) {}
7481

75-
std::unordered_map<std::string, Variable*> vars_;
82+
mutable std::unordered_map<std::string, Variable*> vars_;
7683
mutable std::list<Scope*> kids_;
7784
Scope const* parent_{nullptr};
7885

paddle/framework/var_type.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,32 @@ inline VarDesc::VarType ToVarType(std::type_index type) {
2727
return VarDesc_VarType_LOD_RANK_TABLE;
2828
} else if (type.hash_code() == typeid(LoDTensorArray).hash_code()) {
2929
return VarDesc_VarType_LOD_TENSOR_ARRAY;
30+
} else if (type.hash_code() == typeid(SelectedRows).hash_code()) {
31+
return VarDesc_VarType_SELECTED_ROWS;
3032
} else {
3133
PADDLE_THROW("ToVarType:Unsupported type %s", type.name());
3234
}
3335
}
3436

37+
template <typename Visitor>
38+
inline void VisitVarType(const Variable& var, Visitor visitor) {
39+
switch (ToVarType(var.Type())) {
40+
case VarDesc_VarType_LOD_TENSOR:
41+
visitor(var.Get<framework::LoDTensor>());
42+
return;
43+
case VarDesc_VarType_LOD_RANK_TABLE:
44+
visitor(var.Get<LoDRankTable>());
45+
return;
46+
case VarDesc_VarType_LOD_TENSOR_ARRAY:
47+
visitor(var.Get<LoDTensorArray>());
48+
return;
49+
case VarDesc_VarType_SELECTED_ROWS:
50+
visitor(var.Get<SelectedRows>());
51+
return;
52+
default:
53+
PADDLE_THROW("Not supported visit type, %d", ToVarType(var.Type()));
54+
}
55+
}
56+
3557
} // namespace framework
3658
} // namespace paddle

paddle/gserver/layers/MKLDNNAddtoLayer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void MKLDNNAddtoLayer::reshape(
5454
ow = iw;
5555
reshapeOutput(oh, ow);
5656
resizeOutput(bs, oc * oh * ow);
57-
printSizeInfo();
5857
}
5958

6059
void MKLDNNAddtoLayer::resetFwd(std::vector<primitive>& pipeline,

paddle/gserver/layers/MKLDNNBatchNormLayer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ void MKLDNNBatchNormLayer::reshape(
125125
<< "Input channel can not be changed";
126126
reshapeOutput(oh, ow);
127127
resizeOutput(bs, oc * oh * ow);
128-
printSizeInfo();
129128
}
130129

131130
void MKLDNNBatchNormLayer::resetFwd(std::vector<primitive>& pipeline,

paddle/gserver/layers/MKLDNNConvLayer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ void MKLDNNConvLayer::reshape(
102102

103103
reshapeOutput(oh, ow);
104104
resizeOutput(bs, oc * oh * ow);
105-
106-
printSizeInfo();
107105
}
108106

109107
void MKLDNNConvLayer::resetFwd(std::vector<primitive>& pipeline,

paddle/gserver/layers/MKLDNNConvLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class MKLDNNConvLayer : public MKLDNNLayer {
9292
void printSizeInfo() override {
9393
MKLDNNLayer::printSizeInfo();
9494
VLOG(MKLDNN_SIZES) << getName() << ": fh: " << fh_ << ", fw: " << fw_
95-
<< ": ph: " << ph_ << ", pw: " << pw_ << ", sh: " << sh_
95+
<< ", ph: " << ph_ << ", pw: " << pw_ << ", sh: " << sh_
9696
<< ", sw: " << sw_ << ", dh: " << dh_ << ", dw: " << dw_;
9797
}
9898

paddle/gserver/layers/MKLDNNFcLayer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ void MKLDNNFcLayer::reshape(
8484

8585
reshapeOutput(oh, ow);
8686
resizeOutput(bs, oc);
87-
88-
printSizeInfo();
8987
}
9088

9189
void MKLDNNFcLayer::resetFwd(std::vector<primitive>& pipeline,

paddle/gserver/layers/MKLDNNPoolLayer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ void MKLDNNPoolLayer::reshape(
7171
reshapeOutput(oh, ow);
7272

7373
resizeOutput(bs, oc * oh * ow);
74-
75-
printSizeInfo();
7674
}
7775

7876
void MKLDNNPoolLayer::resetFwd(std::vector<primitive>& pipeline,

0 commit comments

Comments
 (0)