From f5791cf62e4220520292f1da9609b8d9f1baf949 Mon Sep 17 00:00:00 2001 From: Margaret_wangrui Date: Sat, 9 Oct 2021 12:50:35 +0800 Subject: [PATCH] clean pclint --- .../ccsrc/debug/data_dump/dump_json_parser.cc | 2 +- .../frontend/operator/composite/composite.cc | 53 ++----------------- .../optimizer/auto_monad_eliminate.cc | 6 +-- .../jit/static_analysis/order_enforce.cc | 2 +- 4 files changed, 8 insertions(+), 55 deletions(-) diff --git a/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc b/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc index 718b531fafa..c7f281fc803 100644 --- a/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc +++ b/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc @@ -398,7 +398,7 @@ bool DumpJsonParser::IsDumpIter(uint32_t iteration) const { return true; } start = end + 1; - end = iteration_.find("|", start); + end = static_cast(iteration_.find("|", start)); } std::string temp = iteration_.substr(IntToSize(start), IntToSize(end - start)); int range_idx = temp.find("-"); diff --git a/mindspore/ccsrc/frontend/operator/composite/composite.cc b/mindspore/ccsrc/frontend/operator/composite/composite.cc index 710db6b4d6e..20e88c77a1f 100644 --- a/mindspore/ccsrc/frontend/operator/composite/composite.cc +++ b/mindspore/ccsrc/frontend/operator/composite/composite.cc @@ -64,53 +64,6 @@ ElemwiseMap kElemwiseMap = {{"__add__", kPrimScalarAdd}, {"__sub__", kPrimScalar {"__gt__", kPrimScalarGt}, {"__ne__", kPrimScalarNe}, {"__le__", kPrimScalarLe}, {"__ge__", kPrimScalarGe}}; -// copy from python API: reduce. -// Apply a function of two arguments cumulatively to the items of a sequence, -// from left to right, so as to reduce the sequence to a single value.For example, -// reduce(lambda x, y: x + y, [ 1, 2, 3, 4, 5 ]) calculates ((((1 + 2) + 3) + 4) + 5). -AnyPtr Reduce(const OpsFunction &func, const AnyPtrList &list) { - std::shared_ptr ret; - size_t size = list.size(); - if (size < 2) { - MS_LOG(EXCEPTION) << "length of inputs of Reduce is less than 2"; - } - - AnyPtrList input; - input.push_back(list[0]); - input.push_back(list[1]); - ret = std::make_shared(func(input)); - - for (size_t i = 2; i < size; ++i) { - input.clear(); - input.push_back(ret); - input.push_back(list[i]); - ret = std::make_shared(func(input)); - } - - return ret; -} - -AnfNodePtr Reduce(const AnfNodeOpsFunction &func, const std::vector &list) { - size_t size = list.size(); - if (size < 2) { - MS_LOG(EXCEPTION) << "length of inputs of Reduce is less than 2"; - } - - std::vector input; - input.push_back(list[0]); - input.push_back(list[1]); - AnfNodePtr ret = func(input); - - for (size_t i = 2; i < size; ++i) { - input.clear(); - input.push_back(ret); - input.push_back(list[i]); - ret = func(input); - } - - return ret; -} - ValuePtr kCompositeHyperMap = std::make_shared(); void HyperMap::Init() { @@ -236,7 +189,7 @@ AnfNodePtr HyperMap::FullMake(const std::shared_ptr &type, const FuncGrap return false; }); if (is_not_same) { - MS_LOG(EXCEPTION) << "tuple in HyperMap should have same length"; + MS_LOG(EXCEPTION) << "Tuple in HyperMap should have same length"; } // cannot use shared_from_base() also known as this, as it will make a reference cycle on @@ -508,7 +461,7 @@ FuncGraphPtr Tail::GenerateSequeueFuncGraph(const abstract::AbstractSequeuePtr & FuncGraphPtr Tail::GenerateFuncGraph(const AbstractBasePtrList &args_spec_list) { if (args_spec_list.size() != 1) { - MS_LOG(EXCEPTION) << "tail requires a non-empty tuple."; + MS_LOG(EXCEPTION) << "Tail requires a non-empty tuple."; } AbstractBasePtr a = args_spec_list[0]; @@ -925,7 +878,7 @@ FuncGraphPtr TupleAdd::GenerateFuncGraph(const AbstractBasePtrList &args_spec_li << ", function: " << stub->ToString(); return stub; } - MS_LOG(EXCEPTION) << "TupleAdd argument should be tuple,but " << args_spec_list[0]->ToString() << ", " + MS_LOG(EXCEPTION) << "TupleAdd argument should be tuple, but " << args_spec_list[0]->ToString() << ", " << args_spec_list[1]->ToString(); } diff --git a/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc b/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc index ab7f9bc6e9d..41497456377 100644 --- a/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc +++ b/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc @@ -44,7 +44,7 @@ std::vector> GenerateLoadGroups(const FuncGraphPtr &fg, cons IsPrimitiveCNode(cnode, prim::kPrimPartial) || IsPrimitiveCNode(cnode, prim::kPrimSwitch) || IsPrimitiveCNode(cnode, prim::kPrimSwitchLayer); if (is_special_op) { - special_op_indexs->emplace_back(i); + (void)special_op_indexs->emplace_back(i); } // Record param user in toposort nodes. @@ -57,7 +57,7 @@ std::vector> GenerateLoadGroups(const FuncGraphPtr &fg, cons cur_param = input->cast()->input(1); } if (cur_param != nullptr) { - (*unload_users_record)[cur_param].emplace_back(i); + (void)(*unload_users_record)[cur_param].emplace_back(i); } } continue; @@ -349,7 +349,7 @@ bool AutoMonadEliminator::EliminateAutoMonadNode(const FuncGraphManagerPtr &mana fg->set_output(input); changed = true; } - MS_LOG(DEBUG) << "changed: " << changed; + MS_LOG(DEBUG) << "Changed: " << changed; return changed; } } // namespace opt diff --git a/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc b/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc index 6ad735c629c..3e20cacc066 100644 --- a/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc +++ b/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc @@ -40,7 +40,7 @@ class OrderEnforcer { if (IsPrimitiveCNode(node, prim::kPrimUpdateState)) { HandleUpdateState(node); } else if (IsPrimitiveCNode(node, prim::kPrimMakeTuple)) { - // op(MakTuple(Load, ...)) sometimes do not attach update_state, + // op(MakeTuple(Load, ...)) sometimes do not attach update_state, // So need special treatment in order to ensure the exec_order of MakeTuple users. HandleMakeTupleUsers(node); }