From: @mhmotallebi Reviewed-by: @robingrosman Signed-off-by:pull/14814/MERGE
| @@ -84,7 +84,7 @@ Status Iterator::BuildAndLaunchTree(std::shared_ptr<Dataset> ds, int32_t num_epo | |||||
| PullIterator::PullIterator() : pull_consumer_(nullptr) {} | PullIterator::PullIterator() : pull_consumer_(nullptr) {} | ||||
| // Get the next row from the data pipeline. | // Get the next row from the data pipeline. | ||||
| Status PullIterator::GetRows(int32_t num_rows, std::vector<MSTensorVec> *row) { | |||||
| Status PullIterator::GetRows(int32_t num_rows, std::vector<MSTensorVec> *const row) { | |||||
| for (int i = 0; i < num_rows; i++) { | for (int i = 0; i < num_rows; i++) { | ||||
| std::vector<std::shared_ptr<dataset::Tensor>> md_row; | std::vector<std::shared_ptr<dataset::Tensor>> md_row; | ||||
| Status rc = pull_consumer_->GetNextAsVector(&md_row); | Status rc = pull_consumer_->GetNextAsVector(&md_row); | ||||
| @@ -105,7 +105,7 @@ Status PullIterator::GetRows(int32_t num_rows, std::vector<MSTensorVec> *row) { | |||||
| return Status::OK(); | return Status::OK(); | ||||
| } | } | ||||
| Status PullIterator::GetNextRow(MSTensorVec *row) { | |||||
| Status PullIterator::GetNextRow(MSTensorVec *const row) { | |||||
| CHECK_FAIL_RETURN_UNEXPECTED(pull_consumer_ != nullptr, "Consumer is nullptr."); | CHECK_FAIL_RETURN_UNEXPECTED(pull_consumer_ != nullptr, "Consumer is nullptr."); | ||||
| std::vector<std::shared_ptr<dataset::Tensor>> md_row; | std::vector<std::shared_ptr<dataset::Tensor>> md_row; | ||||
| Status rc = pull_consumer_->GetNextAsVector(&md_row); | Status rc = pull_consumer_->GetNextAsVector(&md_row); | ||||
| @@ -40,7 +40,7 @@ std::vector<TensorRow> PullBasedIteratorConsumer::GetRows(int64_t num_rows) { | |||||
| return rows; | return rows; | ||||
| } | } | ||||
| Status PullBasedIteratorConsumer::GetNextAsVector(std::vector<TensorPtr> *out) { | |||||
| Status PullBasedIteratorConsumer::GetNextAsVector(std::vector<TensorPtr> *const out) { | |||||
| RETURN_UNEXPECTED_IF_NULL(out); | RETURN_UNEXPECTED_IF_NULL(out); | ||||
| out->clear(); | out->clear(); | ||||
| @@ -49,7 +49,7 @@ class PullBasedIteratorConsumer { | |||||
| /// Returns the next row in a vector format | /// Returns the next row in a vector format | ||||
| /// \param[out] out std::vector of Tensors | /// \param[out] out std::vector of Tensors | ||||
| /// \return Status error code | /// \return Status error code | ||||
| Status GetNextAsVector(std::vector<TensorPtr> *out); | |||||
| Status GetNextAsVector(std::vector<TensorPtr> *const out); | |||||
| /// Returns the next row in as a map | /// Returns the next row in as a map | ||||
| /// \param[out] out std::map of string to Tensor | /// \param[out] out std::map of string to Tensor | ||||
| @@ -566,7 +566,7 @@ int64_t BatchOp::GetTreeBatchSize() { | |||||
| return start_batch_size_; | return start_batch_size_; | ||||
| } | } | ||||
| Status BatchOp::GetNextRowPullMode(TensorRow *row) { | |||||
| Status BatchOp::GetNextRowPullMode(TensorRow *const row) { | |||||
| std::unique_ptr<TensorQTable> table = std::make_unique<TensorQTable>(); | std::unique_ptr<TensorQTable> table = std::make_unique<TensorQTable>(); | ||||
| child_iterator_ = std::make_unique<ChildIterator>(this, 0, 0); | child_iterator_ = std::make_unique<ChildIterator>(this, 0, 0); | ||||
| int32_t cur_batch_size = 0; | int32_t cur_batch_size = 0; | ||||
| @@ -256,7 +256,10 @@ class BatchOp : public ParallelOp { | |||||
| // @return Status The status code returned | // @return Status The status code returned | ||||
| Status LaunchThreadsAndInitOp(); | Status LaunchThreadsAndInitOp(); | ||||
| Status GetNextRowPullMode(TensorRow *row) override; | |||||
| /// \brief Gets the next row | |||||
| /// \param row[out] - Fetched TensorRow | |||||
| /// \return Status The status code returned | |||||
| Status GetNextRowPullMode(TensorRow *const row) override; | |||||
| #ifdef ENABLE_PYTHON | #ifdef ENABLE_PYTHON | ||||
| // Invoke batch size function with current BatchInfo to generate batch size. | // Invoke batch size function with current BatchInfo to generate batch size. | ||||
| @@ -252,7 +252,7 @@ void DatasetOp::Print(std::ostream &out, bool show_all) const { | |||||
| } | } | ||||
| } | } | ||||
| Status DatasetOp::GetNextRowPullMode(TensorRow *row) { | |||||
| Status DatasetOp::GetNextRowPullMode(TensorRow *const row) { | |||||
| RETURN_UNEXPECTED_IF_NULL(child_[0]); | RETURN_UNEXPECTED_IF_NULL(child_[0]); | ||||
| return child_[0]->GetNextRowPullMode(row); | return child_[0]->GetNextRowPullMode(row); | ||||
| } | } | ||||
| @@ -127,7 +127,10 @@ class DatasetOp : public std::enable_shared_from_this<DatasetOp> { | |||||
| /// \param show_all - A bool to control if you want to show all info or just a summary | /// \param show_all - A bool to control if you want to show all info or just a summary | ||||
| virtual void Print(std::ostream &out, bool show_all) const; | virtual void Print(std::ostream &out, bool show_all) const; | ||||
| virtual Status GetNextRowPullMode(TensorRow *row); | |||||
| /// \brief Gets the next row | |||||
| /// \param row[out] - Fetched TensorRow | |||||
| /// \return Status The status code returned | |||||
| virtual Status GetNextRowPullMode(TensorRow *const row); | |||||
| /// \brief << Stream output operator overload | /// \brief << Stream output operator overload | ||||
| /// \notes This allows you to write the debug print info using stream operators | /// \notes This allows you to write the debug print info using stream operators | ||||
| @@ -145,7 +145,7 @@ Status ProjectOp::ComputeColMap() { | |||||
| return Status::OK(); | return Status::OK(); | ||||
| } | } | ||||
| Status ProjectOp::GetNextRowPullMode(TensorRow *row) { | |||||
| Status ProjectOp::GetNextRowPullMode(TensorRow *const row) { | |||||
| ComputeColMap(); | ComputeColMap(); | ||||
| TensorRow new_row; | TensorRow new_row; | ||||
| RETURN_IF_NOT_OK(child_[0]->GetNextRowPullMode(&new_row)); | RETURN_IF_NOT_OK(child_[0]->GetNextRowPullMode(&new_row)); | ||||
| @@ -101,7 +101,10 @@ class ProjectOp : public PipelineOp { | |||||
| // @return Status The status code returned | // @return Status The status code returned | ||||
| Status EofReceived(int32_t worker_id) override; | Status EofReceived(int32_t worker_id) override; | ||||
| Status GetNextRowPullMode(TensorRow *row) override; | |||||
| /// \brief Gets the next row | |||||
| /// \param row[out] - Fetched TensorRow | |||||
| /// \return Status The status code returned | |||||
| Status GetNextRowPullMode(TensorRow *const row) override; | |||||
| // Op name getter | // Op name getter | ||||
| // @return Name of the current Op | // @return Name of the current Op | ||||
| @@ -483,7 +483,7 @@ Status AlbumOp::ComputeColMap() { | |||||
| return Status::OK(); | return Status::OK(); | ||||
| } | } | ||||
| Status AlbumOp::GetNextRowPullMode(TensorRow *row) { | |||||
| Status AlbumOp::GetNextRowPullMode(TensorRow *const row) { | |||||
| if (image_rows_.empty()) PrescanEntry(); | if (image_rows_.empty()) PrescanEntry(); | ||||
| if (sample_ids_ == nullptr) { | if (sample_ids_ == nullptr) { | ||||
| RETURN_IF_NOT_OK(this->InitSampler()); | RETURN_IF_NOT_OK(this->InitSampler()); | ||||
| @@ -257,7 +257,10 @@ class AlbumOp : public MappableLeafOp { | |||||
| /// \return Status The status code returned | /// \return Status The status code returned | ||||
| Status LaunchThreadsAndInitOp() override; | Status LaunchThreadsAndInitOp() override; | ||||
| Status GetNextRowPullMode(TensorRow *row) override; | |||||
| /// \brief Gets the next row | |||||
| /// \param row[out] - Fetched TensorRow | |||||
| /// \return Status The status code returned | |||||
| Status GetNextRowPullMode(TensorRow *const row) override; | |||||
| /// Private function for computing the assignment of the column name map. | /// Private function for computing the assignment of the column name map. | ||||
| /// \return Status The status code returned | /// \return Status The status code returned | ||||
| @@ -54,7 +54,7 @@ Status TreeAdapterLite::BuildTree(std::shared_ptr<DatasetNode> root_ir) { | |||||
| return Status::OK(); | return Status::OK(); | ||||
| } | } | ||||
| Status TreeAdapterLite::GetNextRow(TensorRow *row) { | |||||
| Status TreeAdapterLite::GetNextRow(TensorRow *const row) { | |||||
| RETURN_UNEXPECTED_IF_NULL(root_); | RETURN_UNEXPECTED_IF_NULL(root_); | ||||
| RETURN_IF_NOT_OK(root_->GetNextRowPullMode(row)); | RETURN_IF_NOT_OK(root_->GetNextRowPullMode(row)); | ||||
| return Status::OK(); | return Status::OK(); | ||||
| @@ -40,7 +40,7 @@ class TreeAdapterLite { | |||||
| Status BuildTree(std::shared_ptr<DatasetNode> root_ir); | Status BuildTree(std::shared_ptr<DatasetNode> root_ir); | ||||
| // Get rows equal to num_rows | // Get rows equal to num_rows | ||||
| Status GetNextRow(TensorRow *row); | |||||
| Status GetNextRow(TensorRow *const row); | |||||
| std::unordered_map<std::string, int32_t> GetColumnNameMap() const { return tree_->root()->column_name_id_map(); } | std::unordered_map<std::string, int32_t> GetColumnNameMap() const { return tree_->root()->column_name_id_map(); } | ||||
| @@ -137,11 +137,14 @@ class PullIterator : public Iterator { | |||||
| /// \brief Constructor | /// \brief Constructor | ||||
| PullIterator(); | PullIterator(); | ||||
| /// \brief Destructor | |||||
| ~PullIterator() = default; | |||||
| /// \brief Function to get next row from the data pipeline. | /// \brief Function to get next row from the data pipeline. | ||||
| /// \note Type of return data is a vector(without column name). | /// \note Type of return data is a vector(without column name). | ||||
| /// \param[out] row - the output tensor row. | /// \param[out] row - the output tensor row. | ||||
| /// \return Returns true if no error encountered else false. | /// \return Returns true if no error encountered else false. | ||||
| Status GetNextRow(MSTensorVec *row) override; | |||||
| Status GetNextRow(MSTensorVec *const row) override; | |||||
| /// \brief Function to get specified rows from the data pipeline. | /// \brief Function to get specified rows from the data pipeline. | ||||
| /// \note Type of return data is a vector(without column name). | /// \note Type of return data is a vector(without column name). | ||||
| @@ -149,7 +152,7 @@ class PullIterator : public Iterator { | |||||
| /// \param[in] num_rows - the number of rows to fetch. | /// \param[in] num_rows - the number of rows to fetch. | ||||
| /// \param[out] row - the output tensor row. | /// \param[out] row - the output tensor row. | ||||
| /// \return Returns true if no error encountered else false. | /// \return Returns true if no error encountered else false. | ||||
| Status GetRows(int32_t num_rows, std::vector<MSTensorVec> *row); | |||||
| Status GetRows(int32_t num_rows, std::vector<MSTensorVec> *const row); | |||||
| /// \brief Method for building and launching the pipeline. | /// \brief Method for building and launching the pipeline. | ||||
| /// \note Consider making this function protected. | /// \note Consider making this function protected. | ||||