@@ -226,15 +226,15 @@ static bool has_fetch_operators(
226226}
227227
228228void Executor::Run (const ProgramDesc& program, Scope* scope,
229- std::map<std::string, const LoDTensor*>& feed_targets,
230- std::map<std::string, LoDTensor*>& fetch_targets,
229+ std::map<std::string, const LoDTensor*>* feed_targets,
230+ std::map<std::string, LoDTensor*>* fetch_targets,
231231 bool create_vars, const std::string& feed_holder_name,
232232 const std::string& fetch_holder_name) {
233233 platform::RecordBlock b (kProgramId );
234234 bool has_feed_ops =
235- has_feed_operators (program.Block (0 ), feed_targets, feed_holder_name);
235+ has_feed_operators (program.Block (0 ), * feed_targets, feed_holder_name);
236236 bool has_fetch_ops =
237- has_fetch_operators (program.Block (0 ), fetch_targets, fetch_holder_name);
237+ has_fetch_operators (program.Block (0 ), * fetch_targets, fetch_holder_name);
238238
239239 ProgramDesc* copy_program = const_cast <ProgramDesc*>(&program);
240240 if (!has_feed_ops || !has_fetch_ops) {
@@ -250,7 +250,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
250250 feed_holder->SetPersistable (true );
251251
252252 int i = 0 ;
253- for (auto & feed_target : feed_targets) {
253+ for (auto & feed_target : (* feed_targets) ) {
254254 std::string var_name = feed_target.first ;
255255 VLOG (3 ) << " feed target's name: " << var_name;
256256
@@ -273,7 +273,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
273273 fetch_holder->SetPersistable (true );
274274
275275 int i = 0 ;
276- for (auto & fetch_target : fetch_targets) {
276+ for (auto & fetch_target : (* fetch_targets) ) {
277277 std::string var_name = fetch_target.first ;
278278 VLOG (3 ) << " fetch target's name: " << var_name;
279279
@@ -361,25 +361,25 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
361361
362362void Executor::RunPreparedContext (
363363 ExecutorPrepareContext* ctx, Scope* scope,
364- std::map<std::string, const LoDTensor*>& feed_targets,
365- std::map<std::string, LoDTensor*>& fetch_targets, bool create_vars,
364+ std::map<std::string, const LoDTensor*>* feed_targets,
365+ std::map<std::string, LoDTensor*>* fetch_targets, bool create_vars,
366366 const std::string& feed_holder_name, const std::string& fetch_holder_name) {
367367 auto & global_block = ctx->prog_ .Block (ctx->block_id_ );
368368
369369 PADDLE_ENFORCE (
370- has_feed_operators (global_block, feed_targets, feed_holder_name),
370+ has_feed_operators (global_block, * feed_targets, feed_holder_name),
371371 " Program in ExecutorPrepareContext should has feed_ops." );
372372 PADDLE_ENFORCE (
373- has_fetch_operators (global_block, fetch_targets, fetch_holder_name),
373+ has_fetch_operators (global_block, * fetch_targets, fetch_holder_name),
374374 " Program in the prepared context should has fetch_ops." );
375375
376376 // map the data of feed_targets to feed_holder
377377 for (auto * op : global_block.AllOps ()) {
378378 if (op->Type () == kFeedOpType ) {
379379 std::string feed_target_name = op->Output (" Out" )[0 ];
380380 int idx = boost::get<int >(op->GetAttr (" col" ));
381- SetFeedVariable (scope, *feed_targets[feed_target_name], feed_holder_name ,
382- idx);
381+ SetFeedVariable (scope, *(* feed_targets) [feed_target_name],
382+ feed_holder_name, idx);
383383 }
384384 }
385385
@@ -390,7 +390,7 @@ void Executor::RunPreparedContext(
390390 if (op->Type () == kFetchOpType ) {
391391 std::string fetch_target_name = op->Input (" X" )[0 ];
392392 int idx = boost::get<int >(op->GetAttr (" col" ));
393- *fetch_targets[fetch_target_name] =
393+ *(* fetch_targets) [fetch_target_name] =
394394 GetFetchVariable (*scope, fetch_holder_name, idx);
395395 }
396396 }
0 commit comments