未验证 提交 e8ee9dc7 编写于 作者: Y yuyang18

Several Polish

上级 0d2ccfbd
...@@ -36,7 +36,7 @@ void ReaderBase::Start() { ...@@ -36,7 +36,7 @@ void ReaderBase::Start() {
} }
} }
ReaderBase::~ReaderBase() {} ReaderBase::~ReaderBase() { Shutdown(); }
} // namespace framework } // namespace framework
} // namespace paddle } // namespace paddle
...@@ -39,9 +39,9 @@ class ReaderBase { ...@@ -39,9 +39,9 @@ class ReaderBase {
protected: protected:
virtual void ReadNextImpl(std::vector<LoDTensor>* out) = 0; virtual void ReadNextImpl(std::vector<LoDTensor>* out) = 0;
virtual void ShutdownImpl() = 0; virtual void ShutdownImpl() {}
virtual void StartImpl() = 0; virtual void StartImpl() {}
ReaderStatus status_{kRunning}; ReaderStatus status_{kRunning};
}; };
...@@ -61,15 +61,8 @@ class DecoratedReader : public ReaderBase { ...@@ -61,15 +61,8 @@ class DecoratedReader : public ReaderBase {
std::shared_ptr<ReaderBase> reader_; std::shared_ptr<ReaderBase> reader_;
}; };
class FileReader : public ReaderBase { // FileReader is just a conceptual class.
public: class FileReader : public ReaderBase {};
FileReader() : ReaderBase() {}
protected:
void ShutdownImpl() override {}
void StartImpl() override {}
};
// The ReaderHolder is used as reader' unified wrapper, // The ReaderHolder is used as reader' unified wrapper,
// making it easier to access different type reader in Variables. // making it easier to access different type reader in Variables.
......
...@@ -56,8 +56,8 @@ class CreatePyReaderOp : public framework::OperatorBase { ...@@ -56,8 +56,8 @@ class CreatePyReaderOp : public framework::OperatorBase {
const std::string& queue_name = Input("blocking_queue"); const std::string& queue_name = Input("blocking_queue");
auto* queue_holder_var = scope.FindVar(queue_name); auto* queue_holder_var = scope.FindVar(queue_name);
PADDLE_ENFORCE( PADDLE_ENFORCE_NOT_NULL(
queue_holder_var != nullptr, queue_holder_var,
"No LoDTensorBlockingQueueHolder variable with name %s found", "No LoDTensorBlockingQueueHolder variable with name %s found",
queue_name); queue_name);
auto* queue_holder = auto* queue_holder =
......
...@@ -22,8 +22,7 @@ template <bool ThreadSafe> ...@@ -22,8 +22,7 @@ template <bool ThreadSafe>
class RecordIOFileReader : public framework::FileReader { class RecordIOFileReader : public framework::FileReader {
public: public:
explicit RecordIOFileReader(const std::string& filename) explicit RecordIOFileReader(const std::string& filename)
: FileReader(), : scanner_(filename),
scanner_(filename),
dev_ctx_(*platform::DeviceContextPool::Instance().Get( dev_ctx_(*platform::DeviceContextPool::Instance().Get(
platform::CPUPlace())) { platform::CPUPlace())) {
if (ThreadSafe) { if (ThreadSafe) {
...@@ -42,7 +41,7 @@ class RecordIOFileReader : public framework::FileReader { ...@@ -42,7 +41,7 @@ class RecordIOFileReader : public framework::FileReader {
} }
} }
void ShutdownImpl() override { scanner_.Reset(); } void StartImpl() override { scanner_.Reset(); }
private: private:
std::unique_ptr<std::mutex> mutex_; std::unique_ptr<std::mutex> mutex_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册