diff --git a/mindspore/ccsrc/minddata/dataset/engine/execution_tree.h b/mindspore/ccsrc/minddata/dataset/engine/execution_tree.h index adf0dc98be..f7d09ce3d7 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/execution_tree.h +++ b/mindspore/ccsrc/minddata/dataset/engine/execution_tree.h @@ -211,7 +211,7 @@ class ExecutionTree { // Return the pointer to the TaskGroup // @return raw pointer to the TaskGroup - TaskGroup *AllTasks() const { return tg_.get(); } + TaskGroup *const AllTasks() const { return tg_.get(); } // Return if the ExecutionTree is at end of epoch status // @return bool - true is ExecutionTree is end of epoch status diff --git a/mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/source/coco_node.cc b/mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/source/coco_node.cc index 5d9953d8b7..e4fd99c4ab 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/source/coco_node.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/source/coco_node.cc @@ -65,7 +65,7 @@ Status CocoNode::ValidateParams() { // Function to build CocoNode Status CocoNode::Build(std::vector> *node_ops) { - CocoOp::TaskType task_type; + CocoOp::TaskType task_type = CocoOp::TaskType::Detection; if (task_ == "Detection") { task_type = CocoOp::TaskType::Detection; } else if (task_ == "Stuff") { @@ -74,6 +74,10 @@ Status CocoNode::Build(std::vector> *node_ops) { task_type = CocoOp::TaskType::Keypoint; } else if (task_ == "Panoptic") { task_type = CocoOp::TaskType::Panoptic; + } else { + std::string err_msg = "Task type:'" + task_ + "' is not supported."; + MS_LOG(ERROR) << err_msg; + RETURN_STATUS_UNEXPECTED(err_msg); } std::unique_ptr schema = std::make_unique(); diff --git a/mindspore/ccsrc/minddata/dataset/engine/opt/post/auto_worker_pass.h b/mindspore/ccsrc/minddata/dataset/engine/opt/post/auto_worker_pass.h index 9c336b5570..d965f103d2 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/opt/post/auto_worker_pass.h +++ b/mindspore/ccsrc/minddata/dataset/engine/opt/post/auto_worker_pass.h @@ -47,6 +47,9 @@ class AutoWorkerPass : public IRTreePass { max_num_workers_(8), thread_cnt_(GlobalContext::Instance()->config_manager()->num_cpu_threads()) {} + /// \brief destructor, by doing "= default", compiler will automatically generate the correct destructor + ~AutoWorkerPass() = default; + Status RunOnTree(std::shared_ptr root_ir, bool *) override; private: @@ -54,6 +57,10 @@ class AutoWorkerPass : public IRTreePass { public: explicit OpWeightPass(const std::map &weight_profile) : IRNodePass(), weight_sum_(0), weight_profile_(weight_profile) {} + + /// \brief destructor, by doing "= default", compiler will automatically generate the correct destructor + ~OpWeightPass() = default; + // this is the base class function which contains the logic to handle most of the pipeline ops // pipeline ops although can't config num_workers it still runs 1 thread they need to be factored into weight Status Visit(std::shared_ptr node, bool *modified) override; diff --git a/mindspore/ccsrc/minddata/dataset/engine/tree_adapter.h b/mindspore/ccsrc/minddata/dataset/engine/tree_adapter.h index 2bee9be54a..b3a3b0fc3d 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/tree_adapter.h +++ b/mindspore/ccsrc/minddata/dataset/engine/tree_adapter.h @@ -51,15 +51,15 @@ class TreeAdapter { // 2. GetNext will return empty row when eoe/eof is obtained Status GetNext(TensorRow *); - // This function will return the root of the execution tree. - std::weak_ptr GetRoot() { return tree_ != nullptr ? tree_->root() : nullptr; } + // unique_ptr overloads operator bool(), will return false if it doesn't manage an object + std::weak_ptr GetRoot() { return tree_ ? tree_->root() : nullptr; } // This function will return the column_name_map once BuildAndPrepare() is called std::unordered_map GetColumnNameMap() const { return column_name_map_; } // This function returns the TaskGroup associated with ExeTree. This is needed by DeviceQueueConsumer // to be able to launch a thread. BuildAndPrepare needs to be called before this function - TaskGroup *AllTasks() const { return tree_ != nullptr ? tree_->AllTasks() : nullptr; } + TaskGroup *const AllTasks() const { return tree_ ? tree_->AllTasks() : nullptr; } Status Launch() const;