From 1353b7451d7580497d70e38dacb3b41781c6caae Mon Sep 17 00:00:00 2001 From: Margaret_wangrui Date: Sun, 25 Apr 2021 10:18:04 +0800 Subject: [PATCH] fix pclint warnings --- .../backend/session/ascend_auto_monad.cc | 16 +++++------ .../ccsrc/backend/session/kernel_graph.cc | 8 +++--- .../ccsrc/backend/session/kernel_graph.h | 2 +- .../ccsrc/backend/session/session_basic.cc | 28 +++++++++---------- .../ccsrc/backend/session/session_basic.h | 2 +- .../jit/static_analysis/auto_monad.cc | 4 +-- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/mindspore/ccsrc/backend/session/ascend_auto_monad.cc b/mindspore/ccsrc/backend/session/ascend_auto_monad.cc index 985d376cdf..cf10bf5f11 100644 --- a/mindspore/ccsrc/backend/session/ascend_auto_monad.cc +++ b/mindspore/ccsrc/backend/session/ascend_auto_monad.cc @@ -1447,13 +1447,13 @@ class ExecuteOrderGenerator { for (auto &graph : all_graphs) { auto out = graph->get_return(); MS_EXCEPTION_IF_NULL(out); - search_list->insert(out->cast()); + (void)search_list->insert(out->cast()); auto nodes = TopoSort(out); for (auto &node : nodes) { MS_EXCEPTION_IF_NULL(node); auto cnode = node->cast(); if (cnode != nullptr) { - all_nodes.insert(cnode); + (void)all_nodes.insert(cnode); } } } @@ -1557,11 +1557,11 @@ class ExecuteOrderGenerator { auto ref_map = graph_->GetRefMap(); std::multimap> ref_multimap; std::set root_inputs(graph_->inputs().begin(), graph_->inputs().end()); - std::transform(ref_map.begin(), ref_map.end(), std::inserter(ref_multimap, ref_multimap.end()), - [](const std::pair, std::pair> &p) - -> std::pair> { - return {p.first.first, {p.first.second, p.second.first, p.second.second}}; - }); + (void)std::transform(ref_map.begin(), ref_map.end(), std::inserter(ref_multimap, ref_multimap.end()), + [](const std::pair, std::pair> &p) + -> std::pair> { + return {p.first.first, {p.first.second, p.second.first, p.second.second}}; + }); auto validate_ref_parameter = [](AnfNodePtr node) -> AnfNodePtr { if (node->isa() && AnfAlgo::CheckPrimitiveType(node, prim::KPrimTransData)) { auto cnode = node->cast(); @@ -1587,7 +1587,7 @@ class ExecuteOrderGenerator { for (auto &node : search_list) { std::set refed_parameters; for (auto [iter, end] = ref_multimap.equal_range(node); iter != end; ++iter) { - refed_parameters.insert(validate_ref_parameter(std::get<1>(iter->second))); + (void)refed_parameters.insert(validate_ref_parameter(std::get<1>(iter->second))); } for (auto &in : node->inputs()) { auto visit_node = AnfAlgo::VisitKernelWithReturnType(in, 0).first; diff --git a/mindspore/ccsrc/backend/session/kernel_graph.cc b/mindspore/ccsrc/backend/session/kernel_graph.cc index 6192e1b45e..538783b9f9 100644 --- a/mindspore/ccsrc/backend/session/kernel_graph.cc +++ b/mindspore/ccsrc/backend/session/kernel_graph.cc @@ -339,7 +339,7 @@ std::vector KernelGraph::SortStartLabelAndEndGoto() { return re_order; } -void KernelGraph::GetLoopNodesByDFS(AnfNodePtr node, uint32_t *loop_num) { +void KernelGraph::GetLoopNodesByDFS(const AnfNodePtr &node, uint32_t *loop_num) { MS_EXCEPTION_IF_NULL(node); auto node_input_it = node_input_edges_.find(node); if (node_input_it == node_input_edges_.end()) { @@ -349,7 +349,7 @@ void KernelGraph::GetLoopNodesByDFS(AnfNodePtr node, uint32_t *loop_num) { if (*loop_num != 0) { return; } - visited_nodes_.insert(node); + (void)visited_nodes_.insert(node); for (auto input_edge : node_input_edges_[node]) { size_t input_num = node_input_num_[input_edge.first]; if (input_num == 0) { @@ -387,8 +387,8 @@ void KernelGraph::GetLoopNodesByDFS(AnfNodePtr node, uint32_t *loop_num) { uint32_t KernelGraph::GetLoopNum(std::map none_zero_nodes) { uint32_t loop_num = 0; - for (auto iter = none_zero_nodes.begin(); iter != none_zero_nodes.end(); iter++) { - auto node = iter->first; + for (auto iter : none_zero_nodes) { + auto node = iter.first; MS_EXCEPTION_IF_NULL(node); if (node_input_num_[node] == 0) { continue; diff --git a/mindspore/ccsrc/backend/session/kernel_graph.h b/mindspore/ccsrc/backend/session/kernel_graph.h index b6766cd284..aa67f1a8c3 100644 --- a/mindspore/ccsrc/backend/session/kernel_graph.h +++ b/mindspore/ccsrc/backend/session/kernel_graph.h @@ -314,7 +314,7 @@ class KernelGraph : public FuncGraph { // checkout whether loop exist in graph void CheckLoop(); uint32_t GetLoopNum(std::map none_zero_nodes); - void GetLoopNodesByDFS(AnfNodePtr node, uint32_t *loop_num); + void GetLoopNodesByDFS(const AnfNodePtr &node, uint32_t *loop_num); // members std::shared_ptr> inputs_; diff --git a/mindspore/ccsrc/backend/session/session_basic.cc b/mindspore/ccsrc/backend/session/session_basic.cc index 14b32f409a..84e33c25df 100644 --- a/mindspore/ccsrc/backend/session/session_basic.cc +++ b/mindspore/ccsrc/backend/session/session_basic.cc @@ -736,7 +736,7 @@ void SessionBasic::GetNewCNodeInputs(const CNodePtr &cnode, KernelGraph *graph, MS_EXCEPTION_IF_NULL(anf); // anf has been created before if (graph->GetBackendAnfByFrontAnf(anf) != nullptr) { - cnode_inputs->emplace_back(graph->GetBackendAnfByFrontAnf(anf)); + (void)cnode_inputs->emplace_back(graph->GetBackendAnfByFrontAnf(anf)); continue; } else if (optimize_depend && input_idx > 1) { cnode_inputs->push_back(NewValueNode(MakeValue(SizeToInt(input_idx)))); @@ -748,7 +748,7 @@ void SessionBasic::GetNewCNodeInputs(const CNodePtr &cnode, KernelGraph *graph, // if input is a value node, auto new_value_node = CreateNewValueNode(anf, graph); if (new_value_node != nullptr) { - cnode_inputs->emplace_back(new_value_node); + (void)cnode_inputs->emplace_back(new_value_node); } continue; } else if (anf->isa()) { @@ -843,17 +843,17 @@ std::vector SessionBasic::CreateCallSwitchInputs(const CNodePtr &cno std::vector partial_inputs = partial_node->inputs(); // Put all call args at the end of partial inputs. for (size_t i = kFirstDataInputIndex; i < cnode->size(); ++i) { - partial_inputs.emplace_back(graph->GetBackendAnfByFrontAnf(cnode->input(i))); + (void)partial_inputs.emplace_back(graph->GetBackendAnfByFrontAnf(cnode->input(i))); } auto new_partial = graph->NewCNode(partial_inputs); - switch_inputs.emplace_back(new_partial); + (void)switch_inputs.emplace_back(new_partial); } } if (switch_inputs.size() < kSwitchInputSize) { MS_LOG(EXCEPTION) << "Switch inputs size: " << switch_inputs.size() << "less than " << kSwitchInputSize; } auto switch_node = graph->NewCNode(switch_inputs); - cnode_inputs.emplace_back(switch_node); + (void)cnode_inputs.emplace_back(switch_node); return cnode_inputs; } @@ -1000,11 +1000,11 @@ std::vector SessionBasic::CreateSwitchOrPartialNode(const CNodePtr & auto partial_node = attr_input->cast(); MS_EXCEPTION_IF_NULL(partial_node); auto partial_inputs = partial_node->inputs(); - std::transform(partial_inputs.begin() + kFirstDataInputIndex, partial_inputs.end(), - std::back_inserter(cnode_inputs), [&graph](const AnfNodePtr &node) { - MS_EXCEPTION_IF_NULL(graph->GetBackendAnfByFrontAnf(node)); - return graph->GetBackendAnfByFrontAnf(node); - }); + (void)std::transform(partial_inputs.begin() + kFirstDataInputIndex, partial_inputs.end(), + std::back_inserter(cnode_inputs), [&graph](const AnfNodePtr &node) { + MS_EXCEPTION_IF_NULL(graph->GetBackendAnfByFrontAnf(node)); + return graph->GetBackendAnfByFrontAnf(node); + }); return cnode_inputs; } else if (AnfAlgo::CheckPrimitiveType(cnode_input, prim::kPrimSwitch)) { return CreateCallSwitchInputs(cnode, graph); @@ -1047,11 +1047,11 @@ void SessionBasic::CreateCNodeInputs(const CNodePtr &cnode, KernelGraph *graph, MS_EXCEPTION_IF_NULL(cnode); MS_EXCEPTION_IF_NULL(graph); if (AnfAlgo::CheckPrimitiveType(cnode, prim::kPrimSwitch)) { - cnode_inputs->emplace_back(graph->GetBackendAnfByFrontAnf(cnode->input(kFirstDataInputIndex))); + (void)cnode_inputs->emplace_back(graph->GetBackendAnfByFrontAnf(cnode->input(kFirstDataInputIndex))); for (size_t index = kFirstBranchInSwitch; index < cnode->inputs().size(); index++) { auto node_input = cnode->input(index); auto switch_input = CreateSwitchInput(cnode, node_input, graph); - cnode_inputs->emplace_back(switch_input); + (void)cnode_inputs->emplace_back(switch_input); } } else { for (size_t input_idx = kFirstDataInputIndex; input_idx < cnode->inputs().size(); input_idx++) { @@ -1059,7 +1059,7 @@ void SessionBasic::CreateCNodeInputs(const CNodePtr &cnode, KernelGraph *graph, MS_EXCEPTION_IF_NULL(anf); // anf has been created before if (graph->GetBackendAnfByFrontAnf(anf) != nullptr) { - cnode_inputs->emplace_back(graph->GetBackendAnfByFrontAnf(anf)); + (void)cnode_inputs->emplace_back(graph->GetBackendAnfByFrontAnf(anf)); continue; } else if (IsValueNode(anf)) { continue; @@ -1069,7 +1069,7 @@ void SessionBasic::CreateCNodeInputs(const CNodePtr &cnode, KernelGraph *graph, } } -CNodePtr SessionBasic::CreateNewCNode(CNodePtr cnode, KernelGraph *graph) { +CNodePtr SessionBasic::CreateNewCNode(const CNodePtr &cnode, KernelGraph *graph) { MS_EXCEPTION_IF_NULL(cnode); MS_EXCEPTION_IF_NULL(graph); std::vector cnode_inputs; diff --git a/mindspore/ccsrc/backend/session/session_basic.h b/mindspore/ccsrc/backend/session/session_basic.h index 7aecdf73c1..cd619cd1d2 100644 --- a/mindspore/ccsrc/backend/session/session_basic.h +++ b/mindspore/ccsrc/backend/session/session_basic.h @@ -108,7 +108,7 @@ class SessionBasic : public std::enable_shared_from_this { CNodePtr CreateNewCNode(const CNodePtr &cnode, KernelGraph *graph, std::unordered_map *other_graph_cnode); - CNodePtr CreateNewCNode(CNodePtr cnode, KernelGraph *graph); + CNodePtr CreateNewCNode(const CNodePtr &cnode, KernelGraph *graph); // get graph id in child graphs by ME front anf node pointer virtual GraphId GetGraphIdByNode(const AnfNodePtr &) const; diff --git a/mindspore/ccsrc/pipeline/jit/static_analysis/auto_monad.cc b/mindspore/ccsrc/pipeline/jit/static_analysis/auto_monad.cc index 2f8cd628bb..cd67cca168 100644 --- a/mindspore/ccsrc/pipeline/jit/static_analysis/auto_monad.cc +++ b/mindspore/ccsrc/pipeline/jit/static_analysis/auto_monad.cc @@ -67,7 +67,7 @@ AnfNodePtr AddMonadParameter(const FuncGraphPtr &func_graph, const std::string & // If io monad parameter added before u monad parameter, should insert u monad before io monad in parameters if (io_monad_location != params_size && abs->isa()) { std::vector params = func_graph->parameters(); - params.insert(params.begin() + io_monad_location, para); + (void)params.insert(params.begin() + io_monad_location, para); func_graph->set_parameters(params); } else { func_graph->add_parameter(para); @@ -217,7 +217,7 @@ class SccFinder { explicit SccFinder(FuncGraphPtr root) : root_(root) {} ~SccFinder() = default; void Run() { (void)Search(root_); } - const SccMap &scc_map() { return scc_map_; } + const SccMap &scc_map() const { return scc_map_; } private: // Save state of a func graph.