From d19e2662bc69ff23f0e80cd57997b27e3454c1d0 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Tue, 30 Jun 2020 14:25:09 +0800 Subject: [PATCH] clear old var in scope, test=develop (#24976) (#25261) --- paddle/fluid/operators/run_program_op.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paddle/fluid/operators/run_program_op.h b/paddle/fluid/operators/run_program_op.h index 7b67f8fad3a..505ce4c0968 100644 --- a/paddle/fluid/operators/run_program_op.h +++ b/paddle/fluid/operators/run_program_op.h @@ -198,7 +198,11 @@ class RunProgramOpKernel : public framework::OpKernel { auto exe_ctx = exe.Prepare(*program, 0, skip_vars); + // get scope and clear old vars framework::Scope &scope = *(out_scope_vec->front()); + auto local_vars = scope.LocalVarNames(); + scope.EraseVars(local_vars); + // share input_vars & parameters into scope details::ShareVarsIntoScope(input_vars, input_var_names, &scope); details::ShareVarsIntoScope(param_vars, param_names, &scope); -- GitLab