Skip to content

Commit b348e15

Browse files
committed
fix rename var
1 parent 2013b1c commit b348e15

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

paddle/fluid/framework/op_desc.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,8 @@ const std::unordered_map<std::string, Attribute> &OpDesc::GetAttrMap() const {
243243
}
244244

245245
void OpDesc::Rename(const std::string &old_name, const std::string &new_name) {
246-
for (auto &input : inputs_) {
247-
std::replace(input.second.begin(), input.second.end(), old_name, new_name);
248-
}
249-
for (auto &output : outputs_) {
250-
std::replace(output.second.begin(), output.second.end(), old_name,
251-
new_name);
252-
}
246+
RenameInput(old_name, new_name);
247+
RenameOutput(old_name, new_name);
253248
need_update_ = true;
254249
}
255250

@@ -274,6 +269,13 @@ void OpDesc::RenameInput(const std::string &old_name,
274269
for (auto &input : inputs_) {
275270
std::replace(input.second.begin(), input.second.end(), old_name, new_name);
276271
}
272+
273+
auto it = attrs_.find(framework::OpProtoAndCheckerMaker::OpRoleVarAttrName());
274+
if (it != attrs_.end()) {
275+
auto &op_vars = boost::get<std::vector<std::string>>(it->second);
276+
std::replace(op_vars.begin(), op_vars.end(), old_name, new_name);
277+
}
278+
277279
need_update_ = true;
278280
}
279281

0 commit comments

Comments
 (0)