diff --git a/paddle/fluid/operators/run_program_op.h b/paddle/fluid/operators/run_program_op.h index 7b67f8fad3a269d2e56c6e29007b1487882a39ec..505ce4c09681d3405227b0e2e8b8b1209a3d359f 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);