提交 22276329 编写于 作者: Y Yu Yang

Change fetch op

上级 76570c2e
...@@ -33,11 +33,6 @@ void FetchOpHandle::Wait(platform::DeviceContext *waited_dev) { ...@@ -33,11 +33,6 @@ void FetchOpHandle::Wait(platform::DeviceContext *waited_dev) {
} }
void FetchOpHandle::WaitAndMergeCPUTensors() const { void FetchOpHandle::WaitAndMergeCPUTensors() const {
// Wait fetch stream done.
for (auto &ctx : dev_ctx_) {
ctx.second->Wait();
}
std::vector<const LoDTensor *> tensors_ptr; std::vector<const LoDTensor *> tensors_ptr;
tensors_ptr.reserve(tensors_.size()); tensors_ptr.reserve(tensors_.size());
for (auto &t : tensors_) { for (auto &t : tensors_) {
...@@ -72,6 +67,8 @@ void FetchOpHandle::RunImpl() { ...@@ -72,6 +67,8 @@ void FetchOpHandle::RunImpl() {
tensors_[i].ShareDataWith(t); tensors_[i].ShareDataWith(t);
tensors_[i].set_lod(t.lod()); tensors_[i].set_lod(t.lod());
} }
this->WaitAndMergeCPUTensors();
} }
} }
......
...@@ -96,12 +96,6 @@ FeedFetchList ThreadedSSAGraphExecutor::Run( ...@@ -96,12 +96,6 @@ FeedFetchList ThreadedSSAGraphExecutor::Run(
for (auto *var : vars) { for (auto *var : vars) {
op->AddInput(var); op->AddInput(var);
} }
dummy_vars.emplace_back();
auto *var = &dummy_vars.back();
var->generated_op_ = nullptr;
op->AddOutput(var);
InsertPendingVar(*var);
InsertPendingOp(*op); InsertPendingOp(*op);
} }
...@@ -176,8 +170,7 @@ FeedFetchList ThreadedSSAGraphExecutor::Run( ...@@ -176,8 +170,7 @@ FeedFetchList ThreadedSSAGraphExecutor::Run(
}; };
// Wait FetchOps. // Wait FetchOps.
for (auto &fetch_op : fetch_ops) { if (!fetch_ops.empty()) {
fetch_op.WaitAndMergeCPUTensors();
sync_computation(); sync_computation();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册