From 139d83fc9aae76be886577d836700345003e6cdd Mon Sep 17 00:00:00 2001 From: mohammad Date: Thu, 8 Apr 2021 13:13:50 -0400 Subject: [PATCH] fix codeDEX and add docstrings --- mindspore/ccsrc/minddata/dataset/api/iterator.cc | 4 ++-- .../dataset/engine/consumers/pull_based_tree_consumer.cc | 2 +- .../dataset/engine/consumers/pull_based_tree_consumer.h | 2 +- .../ccsrc/minddata/dataset/engine/datasetops/batch_op.cc | 2 +- .../ccsrc/minddata/dataset/engine/datasetops/batch_op.h | 5 ++++- .../ccsrc/minddata/dataset/engine/datasetops/dataset_op.cc | 2 +- .../ccsrc/minddata/dataset/engine/datasetops/dataset_op.h | 5 ++++- .../ccsrc/minddata/dataset/engine/datasetops/project_op.cc | 2 +- .../ccsrc/minddata/dataset/engine/datasetops/project_op.h | 5 ++++- .../minddata/dataset/engine/datasetops/source/album_op.cc | 2 +- .../minddata/dataset/engine/datasetops/source/album_op.h | 5 ++++- .../ccsrc/minddata/dataset/engine/tree_adapter_lite.cc | 2 +- .../ccsrc/minddata/dataset/engine/tree_adapter_lite.h | 2 +- mindspore/ccsrc/minddata/dataset/include/iterator.h | 7 +++++-- 14 files changed, 31 insertions(+), 16 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/api/iterator.cc b/mindspore/ccsrc/minddata/dataset/api/iterator.cc index 4db49962f4..cf0d763442 100644 --- a/mindspore/ccsrc/minddata/dataset/api/iterator.cc +++ b/mindspore/ccsrc/minddata/dataset/api/iterator.cc @@ -84,7 +84,7 @@ Status Iterator::BuildAndLaunchTree(std::shared_ptr ds, int32_t num_epo PullIterator::PullIterator() : pull_consumer_(nullptr) {} // Get the next row from the data pipeline. -Status PullIterator::GetRows(int32_t num_rows, std::vector *row) { +Status PullIterator::GetRows(int32_t num_rows, std::vector *const row) { for (int i = 0; i < num_rows; i++) { std::vector> md_row; Status rc = pull_consumer_->GetNextAsVector(&md_row); @@ -105,7 +105,7 @@ Status PullIterator::GetRows(int32_t num_rows, std::vector *row) { return Status::OK(); } -Status PullIterator::GetNextRow(MSTensorVec *row) { +Status PullIterator::GetNextRow(MSTensorVec *const row) { CHECK_FAIL_RETURN_UNEXPECTED(pull_consumer_ != nullptr, "Consumer is nullptr."); std::vector> md_row; Status rc = pull_consumer_->GetNextAsVector(&md_row); diff --git a/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.cc b/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.cc index 8f23c80eb8..d6da54eb30 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.cc @@ -40,7 +40,7 @@ std::vector PullBasedIteratorConsumer::GetRows(int64_t num_rows) { return rows; } -Status PullBasedIteratorConsumer::GetNextAsVector(std::vector *out) { +Status PullBasedIteratorConsumer::GetNextAsVector(std::vector *const out) { RETURN_UNEXPECTED_IF_NULL(out); out->clear(); diff --git a/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.h b/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.h index ac7ef6a1be..096b65d39c 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.h +++ b/mindspore/ccsrc/minddata/dataset/engine/consumers/pull_based_tree_consumer.h @@ -49,7 +49,7 @@ class PullBasedIteratorConsumer { /// Returns the next row in a vector format /// \param[out] out std::vector of Tensors /// \return Status error code - Status GetNextAsVector(std::vector *out); + Status GetNextAsVector(std::vector *const out); /// Returns the next row in as a map /// \param[out] out std::map of string to Tensor diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc index 9d2c0efb3c..d70b45ee3c 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc @@ -575,7 +575,7 @@ int64_t BatchOp::GetTreeBatchSize() { return start_batch_size_; } -Status BatchOp::GetNextRow(TensorRow *row) { +Status BatchOp::GetNextRow(TensorRow *const row) { std::unique_ptr table = std::make_unique(); child_iterator_ = std::make_unique(this, 0, 0); int32_t cur_batch_size = 0; diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.h b/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.h index 196e125a30..b4ef691e9a 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.h +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.h @@ -259,7 +259,10 @@ class BatchOp : public ParallelOp { // @return Status The status code returned Status LaunchThreadsAndInitOp(); - Status GetNextRow(TensorRow *row) override; + /// \brief Gets the next row + /// \param row[out] - Fetched TensorRow + /// \return Status The status code returned + Status GetNextRow(TensorRow *const row) override; #ifdef ENABLE_PYTHON // Invoke batch size function with current BatchInfo to generate batch size. diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.cc index 1e0d591d83..3a3499e1e3 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.cc @@ -252,7 +252,7 @@ void DatasetOp::Print(std::ostream &out, bool show_all) const { } } -Status DatasetOp::GetNextRow(TensorRow *row) { +Status DatasetOp::GetNextRow(TensorRow *const row) { RETURN_UNEXPECTED_IF_NULL(child_[0]); return child_[0]->GetNextRow(row); } diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.h b/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.h index 2f3f44e628..284d3af4db 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.h +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/dataset_op.h @@ -129,7 +129,10 @@ class DatasetOp : public std::enable_shared_from_this { /// \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 Status GetNextRow(TensorRow *row); + /// \brief Gets the next row + /// \param row[out] - Fetched TensorRow + /// \return Status The status code returned + virtual Status GetNextRow(TensorRow *const row); /// \brief << Stream output operator overload /// \notes This allows you to write the debug print info using stream operators diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.cc index 413175d87c..4262a68edf 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.cc @@ -152,7 +152,7 @@ Status ProjectOp::ComputeColMap() { return Status::OK(); } -Status ProjectOp::GetNextRow(TensorRow *row) { +Status ProjectOp::GetNextRow(TensorRow *const row) { ComputeColMap(); TensorRow new_row; RETURN_IF_NOT_OK(child_[0]->GetNextRow(&new_row)); diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.h b/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.h index d741530f6d..bf4e79b473 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.h +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/project_op.h @@ -101,7 +101,10 @@ class ProjectOp : public PipelineOp { // @return Status The status code returned Status EofReceived(int32_t worker_id) override; - Status GetNextRow(TensorRow *row) override; + /// \brief Gets the next row + /// \param row[out] - Fetched TensorRow + /// \return Status The status code returned + Status GetNextRow(TensorRow *const row) override; // Op name getter // @return Name of the current Op diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.cc index afafdf3b2f..e6e2b2a498 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.cc @@ -602,7 +602,7 @@ Status AlbumOp::ComputeColMap() { return Status::OK(); } -Status AlbumOp::GetNextRow(TensorRow *row) { +Status AlbumOp::GetNextRow(TensorRow *const row) { if (image_rows_.empty()) PrescanEntry(); if (sample_ids_ == nullptr) { RETURN_IF_NOT_OK(this->InitSampler()); diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.h b/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.h index 63491ad9f1..21e004546e 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.h +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/album_op.h @@ -291,7 +291,10 @@ class AlbumOp : public ParallelOp, public RandomAccessOp { /// \return Status The status code returned Status Reset() override; - Status GetNextRow(TensorRow *row) override; + /// \brief Gets the next row + /// \param row[out] - Fetched TensorRow + /// \return Status The status code returned + Status GetNextRow(TensorRow *const row) override; // Private function for computing the assignment of the column name map. // @return Status The status code returned diff --git a/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.cc b/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.cc index 1865afbd92..d9f2072380 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.cc @@ -54,7 +54,7 @@ Status TreeAdapterLite::BuildTree(std::shared_ptr root_ir) { return Status::OK(); } -Status TreeAdapterLite::GetNextRow(TensorRow *row) { +Status TreeAdapterLite::GetNextRow(TensorRow *const row) { RETURN_UNEXPECTED_IF_NULL(root_); RETURN_IF_NOT_OK(root_->GetNextRow(row)); return Status::OK(); diff --git a/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.h b/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.h index c42da20718..2fe54c488d 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.h +++ b/mindspore/ccsrc/minddata/dataset/engine/tree_adapter_lite.h @@ -40,7 +40,7 @@ class TreeAdapterLite { Status BuildTree(std::shared_ptr root_ir); // Get rows equal to num_rows - Status GetNextRow(TensorRow *row); + Status GetNextRow(TensorRow *const row); std::unordered_map GetColumnNameMap() const { return tree_->root()->column_name_id_map(); } diff --git a/mindspore/ccsrc/minddata/dataset/include/iterator.h b/mindspore/ccsrc/minddata/dataset/include/iterator.h index 799dc1d877..ce77d5b980 100644 --- a/mindspore/ccsrc/minddata/dataset/include/iterator.h +++ b/mindspore/ccsrc/minddata/dataset/include/iterator.h @@ -138,11 +138,14 @@ class PullIterator : public Iterator { /// \brief Constructor PullIterator(); + /// \brief Destructor + ~PullIterator() = default; + /// \brief Function to get next row from the data pipeline. /// \note Type of return data is a vector(without column name). /// \param[out] row - the output tensor row. /// \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. /// \note Type of return data is a vector(without column name). @@ -150,7 +153,7 @@ class PullIterator : public Iterator { /// \param[in] num_rows - the number of rows to fetch. /// \param[out] row - the output tensor row. /// \return Returns true if no error encountered else false. - Status GetRows(int32_t num_rows, std::vector *row); + Status GetRows(int32_t num_rows, std::vector *const row); /// \brief Method for building and launching the pipeline. /// \note Consider making this function protected.