Skip to content

Commit 907e6d0

Browse files
authored
Fix bug in SetAttrDescVisitor (#7165)
* fix bug in SetAttrDescVisitor * add comments
1 parent cbe25b3 commit 907e6d0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

paddle/framework/op_desc.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,13 @@ struct SetAttrDescVisitor : public boost::static_visitor<void> {
260260
void operator()(int v) const { attr_->set_i(v); }
261261
void operator()(float v) const { attr_->set_f(v); }
262262
void operator()(const std::string &v) const { attr_->set_s(v); }
263-
void operator()(bool b) const { attr_->set_b(b); }
263+
264+
// Please refer to https://github.com/PaddlePaddle/Paddle/issues/7162
265+
template <class T,
266+
class = typename std::enable_if<std::is_same<bool, T>::value>::type>
267+
void operator()(T b) const {
268+
attr_->set_b(b);
269+
}
264270

265271
void operator()(const std::vector<int> &v) const {
266272
VectorToRepeated(v, attr_->mutable_ints());
@@ -274,9 +280,7 @@ struct SetAttrDescVisitor : public boost::static_visitor<void> {
274280
void operator()(const std::vector<bool> &v) const {
275281
VectorToRepeated(v, attr_->mutable_bools());
276282
}
277-
void operator()(proto::BlockDesc *desc) const {
278-
attr_->set_block_idx(desc->idx());
279-
}
283+
void operator()(BlockDesc *desc) const { attr_->set_block_idx(desc->ID()); }
280284
void operator()(boost::blank) const { PADDLE_THROW("Unexpected branch"); }
281285
};
282286

0 commit comments

Comments
 (0)