Skip to content

Commit a08f6a1

Browse files
authored
Merge pull request #12886 from panyx0718/ir5
small fix of op_desc
2 parents 2328a69 + ec5cb37 commit a08f6a1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

paddle/fluid/framework/op_desc.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ OpDesc::OpDesc(const std::string &type, const VariableNameMap &inputs,
9595
need_update_ = true;
9696
}
9797

98+
OpDesc::OpDesc(const OpDesc &other, BlockDesc *block) {
99+
CopyFrom(other);
100+
block_ = block;
101+
need_update_ = true;
102+
}
103+
98104
void OpDesc::CopyFrom(const OpDesc &op_desc) {
99105
desc_.set_type(op_desc.Type());
100106
inputs_ = op_desc.inputs_;
@@ -131,8 +137,7 @@ OpDesc::OpDesc(const proto::OpDesc &desc, BlockDesc *block)
131137
for (const proto::OpDesc::Attr &attr : desc_.attrs()) {
132138
std::string attr_name = attr.name();
133139
// The sub_block referred to by the BLOCK attr hasn't been added
134-
// to ProgramDesc class yet, we skip setting BLOCK attr here.
135-
// TODO(paddle-dev): Need copy fix this to copy Block as well.
140+
// to ProgramDesc class yet, we skip setting BLOCK/BLOCKS attr here.
136141
if (attr.type() != proto::AttrType::BLOCK &&
137142
attr.type() != proto::AttrType::BLOCKS) {
138143
attrs_[attr_name] = GetAttrValue(attr);

paddle/fluid/framework/op_desc.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ class OpDesc {
3737

3838
explicit OpDesc(BlockDesc *block) : block_(block) {}
3939

40-
OpDesc(const OpDesc &other, BlockDesc *block) {
41-
*this = other;
42-
block_ = block;
43-
need_update_ = true;
44-
}
40+
OpDesc(const OpDesc &other, BlockDesc *block);
4541

4642
void CopyFrom(const OpDesc &op_desc);
4743

0 commit comments

Comments
 (0)