提交 55e4b89f 编写于 作者: F fengjiayi

remove local_buffer_

上级 7bb18433
...@@ -73,7 +73,6 @@ class DoubleBufferReader : public framework::DecoratedReader { ...@@ -73,7 +73,6 @@ class DoubleBufferReader : public framework::DecoratedReader {
framework::Channel<Item>* buffer_; framework::Channel<Item>* buffer_;
platform::Place place_; platform::Place place_;
std::vector<std::unique_ptr<platform::DeviceContext>> ctxs_; std::vector<std::unique_ptr<platform::DeviceContext>> ctxs_;
mutable Item local_buffer_;
}; };
class CreateDoubleBufferReaderOp : public framework::OperatorBase { class CreateDoubleBufferReaderOp : public framework::OperatorBase {
...@@ -128,12 +127,9 @@ class CreateDoubleBufferReaderOpMaker : public DecoratedReaderMakerBase { ...@@ -128,12 +127,9 @@ class CreateDoubleBufferReaderOpMaker : public DecoratedReaderMakerBase {
}; };
bool DoubleBufferReader::HasNext() const { bool DoubleBufferReader::HasNext() const {
if (local_buffer_.payloads_.empty()) { while (!buffer_->IsClosed() && !buffer_->CanReceive()) {
bool ok = buffer_->Receive(&local_buffer_);
return ok;
} else {
return true;
} }
return buffer_->CanReceive()
} }
void DoubleBufferReader::ReadNext(std::vector<framework::LoDTensor>* out) { void DoubleBufferReader::ReadNext(std::vector<framework::LoDTensor>* out) {
...@@ -141,10 +137,11 @@ void DoubleBufferReader::ReadNext(std::vector<framework::LoDTensor>* out) { ...@@ -141,10 +137,11 @@ void DoubleBufferReader::ReadNext(std::vector<framework::LoDTensor>* out) {
PADDLE_THROW("There is no next data!"); PADDLE_THROW("There is no next data!");
} }
*out = local_buffer_.payloads_; Item batch;
local_buffer_.payloads_.clear(); buffer_->Receive(&batch);
if (local_buffer_.ctx_) { *out = batch.payload_;
local_buffer_.ctx_->Wait(); if (batch.ctx_) {
batch.ctx_->Wait();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册