提交 2e42b31f 编写于 作者: F fengjiayi

refine code

上级 4b395b08
...@@ -28,7 +28,7 @@ class CustomReader : public framework::DecoratedReader { ...@@ -28,7 +28,7 @@ class CustomReader : public framework::DecoratedReader {
: DecoratedReader(reader), : DecoratedReader(reader),
sub_block_(sub_block), sub_block_(sub_block),
scope_(scope), scope_(scope),
dev_place_(dev_place), exe_(framework::Executor(dev_place)),
source_var_names_(source_var_names), source_var_names_(source_var_names),
sink_var_names_(sink_var_names) {} sink_var_names_(sink_var_names) {}
...@@ -43,7 +43,7 @@ class CustomReader : public framework::DecoratedReader { ...@@ -43,7 +43,7 @@ class CustomReader : public framework::DecoratedReader {
private: private:
const framework::BlockDesc* sub_block_; const framework::BlockDesc* sub_block_;
const framework::Scope* scope_; const framework::Scope* scope_;
platform::Place dev_place_; framework::Executor exe_;
std::vector<std::string> source_var_names_; std::vector<std::string> source_var_names_;
std::vector<std::string> sink_var_names_; std::vector<std::string> sink_var_names_;
...@@ -160,9 +160,8 @@ void CustomReader::ReadNext(std::vector<framework::LoDTensor>* out) { ...@@ -160,9 +160,8 @@ void CustomReader::ReadNext(std::vector<framework::LoDTensor>* out) {
tensor->set_lod(underlying_outs[i].lod()); tensor->set_lod(underlying_outs[i].lod());
} }
// 2. Run the sub-block. // 2. Run the sub-block.
framework::Executor executor(dev_place_);
framework::ProgramDesc* program = sub_block_->Program(); 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. // 3. Copy LoDTensors from sink variables to out.
out->resize(sink_var_names_.size()); out->resize(sink_var_names_.size());
for (size_t i = 0; i < sink_var_names_.size(); ++i) { for (size_t i = 0; i < sink_var_names_.size(); ++i) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册