From 437520474cec5c7b57eb955ee2f260553bd033c1 Mon Sep 17 00:00:00 2001 From: chengduo Date: Tue, 4 Jun 2019 22:55:42 +0800 Subject: [PATCH] fix DropLocalExeScopes (#17829) test=develop --- .../details/scope_buffered_ssa_graph_executor.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.cc b/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.cc index a0fb20a647..06a454f4ad 100644 --- a/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.cc @@ -65,11 +65,14 @@ void ScopeBufferedSSAGraphExecutor::DropLocalExeScopes() { for (auto p : places_) { platform::DeviceContextPool::Instance().Get(p)->Wait(); } + for (auto &scope : local_scopes_) { - auto &local_scope = - *scope->Var(details::kLocalExecScopeName)->GetMutable(); - scope->DeleteScope(local_scope); - VLOG(3) << "Drop local execution scope: " << local_scope; + auto *local_scope_var = scope->FindLocalVar(details::kLocalExecScopeName); + if (local_scope_var != nullptr) { + auto &local_scope = *local_scope_var->GetMutable(); + scope->DeleteScope(local_scope); + VLOG(3) << "Drop local execution scope: " << local_scope; + } } } -- GitLab