Skip to content

Commit 4375204

Browse files
author
chengduo
authored
fix DropLocalExeScopes (#17829)
test=develop
1 parent 5032656 commit 4375204

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ void ScopeBufferedSSAGraphExecutor::DropLocalExeScopes() {
6565
for (auto p : places_) {
6666
platform::DeviceContextPool::Instance().Get(p)->Wait();
6767
}
68+
6869
for (auto &scope : local_scopes_) {
69-
auto &local_scope =
70-
*scope->Var(details::kLocalExecScopeName)->GetMutable<Scope *>();
71-
scope->DeleteScope(local_scope);
72-
VLOG(3) << "Drop local execution scope: " << local_scope;
70+
auto *local_scope_var = scope->FindLocalVar(details::kLocalExecScopeName);
71+
if (local_scope_var != nullptr) {
72+
auto &local_scope = *local_scope_var->GetMutable<Scope *>();
73+
scope->DeleteScope(local_scope);
74+
VLOG(3) << "Drop local execution scope: " << local_scope;
75+
}
7376
}
7477
}
7578

0 commit comments

Comments
 (0)