From 2e42b31f45a32878a3a10b1fd839a31edcf81fb0 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Wed, 23 May 2018 17:13:54 +0800 Subject: [PATCH] refine code --- paddle/fluid/operators/reader/create_custom_reader_op.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/operators/reader/create_custom_reader_op.cc b/paddle/fluid/operators/reader/create_custom_reader_op.cc index a8d5e4e9a..659f7d595 100644 --- a/paddle/fluid/operators/reader/create_custom_reader_op.cc +++ b/paddle/fluid/operators/reader/create_custom_reader_op.cc @@ -28,7 +28,7 @@ class CustomReader : public framework::DecoratedReader { : DecoratedReader(reader), sub_block_(sub_block), scope_(scope), - dev_place_(dev_place), + exe_(framework::Executor(dev_place)), source_var_names_(source_var_names), sink_var_names_(sink_var_names) {} @@ -43,7 +43,7 @@ class CustomReader : public framework::DecoratedReader { private: const framework::BlockDesc* sub_block_; const framework::Scope* scope_; - platform::Place dev_place_; + framework::Executor exe_; std::vector source_var_names_; std::vector sink_var_names_; @@ -160,9 +160,8 @@ void CustomReader::ReadNext(std::vector* out) { tensor->set_lod(underlying_outs[i].lod()); } // 2. Run the sub-block. - framework::Executor executor(dev_place_); framework::ProgramDesc* program = sub_block_->Program(); - executor.Run(*program, exe_scope, sub_block_->ID(), false, true); + exe_.Run(*program, exe_scope, sub_block_->ID(), false, true); // 3. Copy LoDTensors from sink variables to out. out->resize(sink_var_names_.size()); for (size_t i = 0; i < sink_var_names_.size(); ++i) { -- GitLab