diff --git a/paddle/fluid/framework/executor_cache.cc b/paddle/fluid/framework/executor_cache.cc index 3c351ca39c5d8d4cc5532b5a2f0c656823d3cdd1..4d39c1a533d33cf18969d225ac5ff76e8e56d9aa 100644 --- a/paddle/fluid/framework/executor_cache.cc +++ b/paddle/fluid/framework/executor_cache.cc @@ -386,6 +386,7 @@ std::unique_ptr<::ir::Program> ConstructFowardIrProgram( op_desc->SetOutput("out", {name}); } + std::set input_param_names; for (auto ¶m : params) { auto &name = param.name(); auto place = param.place().GetType(); @@ -398,6 +399,8 @@ std::unique_ptr<::ir::Program> ConstructFowardIrProgram( op_desc->SetAttr("place", static_cast(place)); op_desc->SetAttr("name", name); op_desc->SetOutput("out", {name}); + + input_param_names.insert(name); } std::set set_parameter_names; @@ -419,6 +422,10 @@ std::unique_ptr<::ir::Program> ConstructFowardIrProgram( continue; } + if (input_param_names.count(name)) { + continue; + } + auto op_desc = local_program.MutableBlock(0)->AppendOp(); op_desc->SetType("shadow_output"); op_desc->SetAttr("name", name);