From 9c92d0304fd34236d0b123fb5def0725596865c3 Mon Sep 17 00:00:00 2001 From: dzhwinter Date: Tue, 19 Feb 2019 16:32:56 +0800 Subject: [PATCH] fix default value. test=develop --- paddle/fluid/framework/details/memory_optimize_pass.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/details/memory_optimize_pass.cc b/paddle/fluid/framework/details/memory_optimize_pass.cc index b35b967c72d..93d08649db2 100644 --- a/paddle/fluid/framework/details/memory_optimize_pass.cc +++ b/paddle/fluid/framework/details/memory_optimize_pass.cc @@ -235,7 +235,9 @@ void MemoryOptimizePass::RenameVarInGraphDesc(const std::string& var, auto* op_desc = op->Op(); op_desc->RenameInput(var, cache_var); op_desc->RenameOutput(var, cache_var); - if (op_desc->Block()->HasVar(var)) op_desc->Block()->RemoveVar(var); + if (op_desc->Block() != nullptr && op_desc->Block()->HasVar(var)) { + op_desc->Block()->RemoveVar(var); + } op_desc->Flush(); } } -- GitLab