Skip to content

Commit 8cd17c0

Browse files
authored
Merge pull request #13718 from sneaxiy/fix_eager_deletion
Fix eager deletion bug in fetch_op_handle
2 parents 8e63bc2 + 9606b37 commit 8cd17c0

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
@@ -250,6 +250,13 @@ void ParallelExecutor::Run(const std::vector<std::string> &fetch_tensors,
250250
#ifdef PADDLE_WITH_CUDA
251251
if (!gcs_.empty()) {
252252
ResetReferenceCount();
253+
for (auto &pair : cur_ref_cnts_) {
254+
auto &name_map = *(pair.second);
255+
for (auto &fetch_name : fetch_tensors) {
256+
name_map.erase(fetch_name);
257+
}
258+
name_map.erase(fetched_var_name);
259+
}
253260
}
254261
#endif
255262
auto fetch_data = member_->executor_->Run(fetch_tensors);

0 commit comments

Comments
 (0)