From 222763296f31ff723260155ad0b0169c285212cd Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 27 Mar 2018 14:02:16 +0800 Subject: [PATCH] Change fetch op --- paddle/fluid/framework/details/fetch_op_handle.cc | 7 ++----- .../framework/details/threaded_ssa_graph_executor.cc | 9 +-------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/paddle/fluid/framework/details/fetch_op_handle.cc b/paddle/fluid/framework/details/fetch_op_handle.cc index 26c09eb8eb..9ed974151f 100644 --- a/paddle/fluid/framework/details/fetch_op_handle.cc +++ b/paddle/fluid/framework/details/fetch_op_handle.cc @@ -33,11 +33,6 @@ void FetchOpHandle::Wait(platform::DeviceContext *waited_dev) { } void FetchOpHandle::WaitAndMergeCPUTensors() const { - // Wait fetch stream done. - for (auto &ctx : dev_ctx_) { - ctx.second->Wait(); - } - std::vector tensors_ptr; tensors_ptr.reserve(tensors_.size()); for (auto &t : tensors_) { @@ -72,6 +67,8 @@ void FetchOpHandle::RunImpl() { tensors_[i].ShareDataWith(t); tensors_[i].set_lod(t.lod()); } + + this->WaitAndMergeCPUTensors(); } } diff --git a/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc b/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc index 7d1f7e46b8..7cfd668379 100644 --- a/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc @@ -96,12 +96,6 @@ FeedFetchList ThreadedSSAGraphExecutor::Run( for (auto *var : vars) { op->AddInput(var); } - - dummy_vars.emplace_back(); - auto *var = &dummy_vars.back(); - var->generated_op_ = nullptr; - op->AddOutput(var); - InsertPendingVar(*var); InsertPendingOp(*op); } @@ -176,8 +170,7 @@ FeedFetchList ThreadedSSAGraphExecutor::Run( }; // Wait FetchOps. - for (auto &fetch_op : fetch_ops) { - fetch_op.WaitAndMergeCPUTensors(); + if (!fetch_ops.empty()) { sync_computation(); } -- GitLab