Skip to content

Commit e5778b8

Browse files
authored
Merge pull request #13719 from sneaxiy/release/1.0.0
Cherry-pick 'Fix eager deletion bug in fetch_op_handle'
2 parents 3b7e20b + ec8880c commit e5778b8

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

paddle/fluid/framework/details/reference_count_pass.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ std::unique_ptr<ir::Graph> ReferenceCountPass::ApplyImpl(
8080
// This is weird but there is really some variables without var_desc
8181
// in computation_op
8282
if (var_desc == nullptr) {
83-
if (compute_op->Node()->Op()->Block()->FindVar(var_name) == nullptr)
84-
continue;
85-
} else {
86-
if (var_desc->Persistable()) continue;
87-
auto var_type = var_desc->Proto()->type().type();
88-
if (var_type != proto::VarType::LOD_TENSOR &&
89-
var_type != proto::VarType::SELECTED_ROWS) {
90-
continue;
91-
}
83+
var_desc = compute_op->Node()->Op()->Block()->FindVar(var_name);
84+
if (var_desc == nullptr) continue;
85+
}
86+
87+
if (var_desc->Persistable()) continue;
88+
auto var_type = var_desc->Proto()->type().type();
89+
if (var_type != proto::VarType::LOD_TENSOR &&
90+
var_type != proto::VarType::SELECTED_ROWS) {
91+
continue;
9292
}
9393

9494
// compute op only runs in one device

paddle/fluid/framework/parallel_executor.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ void ParallelExecutor::Run(const std::vector<std::string> &fetch_tensors,
319319
#ifdef PADDLE_WITH_CUDA
320320
if (!gcs_.empty()) {
321321
ResetReferenceCount();
322+
for (auto &pair : cur_ref_cnts_) {
323+
auto &name_map = *(pair.second);
324+
for (auto &fetch_name : fetch_tensors) {
325+
name_map.erase(fetch_name);
326+
}
327+
name_map.erase(fetched_var_name);
328+
}
322329
}
323330
#endif
324331
auto fetch_data = member_->executor_->Run(fetch_tensors);

0 commit comments

Comments
 (0)