| @@ -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<CNodePtr>()); | |||
| (void)search_list->insert(out->cast<CNodePtr>()); | |||
| auto nodes = TopoSort(out); | |||
| for (auto &node : nodes) { | |||
| MS_EXCEPTION_IF_NULL(node); | |||
| auto cnode = node->cast<CNodePtr>(); | |||
| 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<AnfNodePtr, std::tuple<size_t, AnfNodePtr, size_t>> ref_multimap; | |||
| std::set<AnfNodePtr> 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<AnfNodePtr, size_t>, std::pair<AnfNodePtr, size_t>> &p) | |||
| -> std::pair<AnfNodePtr, std::tuple<size_t, AnfNodePtr, size_t>> { | |||
| 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<AnfNodePtr, size_t>, std::pair<AnfNodePtr, size_t>> &p) | |||
| -> std::pair<AnfNodePtr, std::tuple<size_t, AnfNodePtr, size_t>> { | |||
| return {p.first.first, {p.first.second, p.second.first, p.second.second}}; | |||
| }); | |||
| auto validate_ref_parameter = [](AnfNodePtr node) -> AnfNodePtr { | |||
| if (node->isa<CNode>() && AnfAlgo::CheckPrimitiveType(node, prim::KPrimTransData)) { | |||
| auto cnode = node->cast<CNodePtr>(); | |||
| @@ -1587,7 +1587,7 @@ class ExecuteOrderGenerator { | |||
| for (auto &node : search_list) { | |||
| std::set<AnfNodePtr> 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; | |||
| @@ -339,7 +339,7 @@ std::vector<CNodePtr> 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<AnfNodePtr, size_t> 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; | |||
| @@ -314,7 +314,7 @@ class KernelGraph : public FuncGraph { | |||
| // checkout whether loop exist in graph | |||
| void CheckLoop(); | |||
| uint32_t GetLoopNum(std::map<AnfNodePtr, size_t> none_zero_nodes); | |||
| void GetLoopNodesByDFS(AnfNodePtr node, uint32_t *loop_num); | |||
| void GetLoopNodesByDFS(const AnfNodePtr &node, uint32_t *loop_num); | |||
| // members | |||
| std::shared_ptr<std::vector<AnfNodePtr>> inputs_; | |||
| @@ -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<Parameter>()) { | |||
| @@ -843,17 +843,17 @@ std::vector<AnfNodePtr> SessionBasic::CreateCallSwitchInputs(const CNodePtr &cno | |||
| std::vector<AnfNodePtr> 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<AnfNodePtr> SessionBasic::CreateSwitchOrPartialNode(const CNodePtr & | |||
| auto partial_node = attr_input->cast<CNodePtr>(); | |||
| 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<None>(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<AnfNodePtr> cnode_inputs; | |||
| @@ -108,7 +108,7 @@ class SessionBasic : public std::enable_shared_from_this<SessionBasic> { | |||
| CNodePtr CreateNewCNode(const CNodePtr &cnode, KernelGraph *graph, | |||
| std::unordered_map<AnfNodePtr, AnfNodePtr> *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; | |||
| @@ -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<abstract::AbstractUMonad>()) { | |||
| std::vector<AnfNodePtr> 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. | |||