From d6c87c0bdbb39d4e70e9df3048d29e365976116f Mon Sep 17 00:00:00 2001 From: zhangzhaoju Date: Thu, 27 May 2021 19:34:18 +0800 Subject: [PATCH] pclint clean --- .../frontend/optimizer/irpass/special_op_eliminate.h | 2 +- mindspore/ccsrc/pipeline/jit/pass.cc | 6 +++--- mindspore/core/abstract/prim_maths.cc | 10 +++++----- mindspore/core/ir/meta_tensor.cc | 8 +++----- mindspore/core/ir/meta_tensor.h | 2 +- mindspore/core/utils/check_convert_utils.cc | 5 ++--- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h index 292696c18dc..c1e7212508e 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h @@ -293,7 +293,7 @@ class ZeroLikeFillZero : public AnfVisitor { } tensor::TensorPtr new_tensor_ptr = std::make_shared(tensor_type_ptr->type_id(), tensor_shape); - size_t mem_size = GetTypeByte(tensor_type_ptr) * LongToSize(new_tensor_ptr->ElementsNum()); + size_t mem_size = GetTypeByte(tensor_type_ptr) * IntToSize(new_tensor_ptr->ElementsNum()); char *data = reinterpret_cast(new_tensor_ptr->data_c()); (void)memset_s(data, mem_size, 0, mem_size); diff --git a/mindspore/ccsrc/pipeline/jit/pass.cc b/mindspore/ccsrc/pipeline/jit/pass.cc index a052ad4cb94..67b82330a07 100644 --- a/mindspore/ccsrc/pipeline/jit/pass.cc +++ b/mindspore/ccsrc/pipeline/jit/pass.cc @@ -92,7 +92,7 @@ bool TransformTopGraphPass(const ResourcePtr &res) { AbstractBasePtrList abs_spec_list; auto ¶ms = func_graph->parameters(); std::transform(params.begin(), params.end(), std::back_inserter(abs_spec_list), - [](AnfNodePtr node) { return node->abstract(); }); + [](const AnfNodePtr &node) { return node->abstract(); }); res->set_args_spec(abs_spec_list); } return true; @@ -429,7 +429,7 @@ OptPassGroupMap GetOptPassesPynativeElim(const opt::irpass::OptimizeIRPassLib &i return map; } -OptPassGroupMap GetOptPassesC(const opt::irpass::OptimizeIRPassLib &irpass) { +OptPassGroupMap GetOptPassesC(const opt::irpass::OptimizeIRPassLib &) { return OptPassGroupMap({{"renormalize", opt::OptPassConfig::Renormalize()}}); } @@ -466,7 +466,7 @@ OptPassGroupMap GetPreparePhases(const opt::irpass::OptimizeIRPassLib &irpass) { return map; } -OptPassGroupMap GetAfterRecomputePass(const opt::irpass::OptimizeIRPassLib &irpass) { +OptPassGroupMap GetAfterRecomputePass(const opt::irpass::OptimizeIRPassLib &) { OptPassGroupMap map({{"cse", opt::OptPassConfig(opt::CSEPass(false))}}); return map; } diff --git a/mindspore/core/abstract/prim_maths.cc b/mindspore/core/abstract/prim_maths.cc index b8f8c11221f..7fad5c0be1c 100644 --- a/mindspore/core/abstract/prim_maths.cc +++ b/mindspore/core/abstract/prim_maths.cc @@ -196,7 +196,7 @@ AbstractBasePtr InferImplReduceFunc(const AnalysisEnginePtr &, const PrimitivePt return std::make_shared(input_x->element(), std::make_shared(shape)); } -AbstractBasePtr InferImplBinaryBase(const AnalysisEnginePtr &engine_ptr, const PrimitivePtr &primitive, +AbstractBasePtr InferImplBinaryBase(const AnalysisEnginePtr &, const PrimitivePtr &primitive, const AbstractBasePtrList &args_spec_list) { const std::string op_name = primitive->name(); constexpr size_t args_size = 2; @@ -337,8 +337,8 @@ AbstractBasePtr InferImplMatMul(const AnalysisEnginePtr &, const PrimitivePtr &p ShapeVector x_max_shape = x->shape()->max_shape(); ShapeVector y_min_shape = y->shape()->min_shape(); ShapeVector y_max_shape = y->shape()->max_shape(); - (void)CheckMinMaxShape(x_shp, &x_min_shape, &x_max_shape); - (void)CheckMinMaxShape(y_shp, &y_min_shape, &y_max_shape); + CheckMinMaxShape(x_shp, &x_min_shape, &x_max_shape); + CheckMinMaxShape(y_shp, &y_min_shape, &y_max_shape); // Additional check for dynamic shape // Last infer will be real shape values bool x_not_dyn = std::all_of(x_shp.begin(), x_shp.end(), [](int64_t value) { return value != Shape::SHP_ANY; }); @@ -394,8 +394,8 @@ AbstractBasePtr InferImplBatchMatMul(const AnalysisEnginePtr &, const PrimitiveP ShapeVector x_max_shape = x->shape()->max_shape(); ShapeVector y_min_shape = y->shape()->min_shape(); ShapeVector y_max_shape = y->shape()->max_shape(); - (void)CheckMinMaxShape(x_shp, &x_min_shape, &x_max_shape); - (void)CheckMinMaxShape(y_shp, &y_min_shape, &y_max_shape); + CheckMinMaxShape(x_shp, &x_min_shape, &x_max_shape); + CheckMinMaxShape(y_shp, &y_min_shape, &y_max_shape); // Additional check for dynamic shape // Last infer will be real shape values bool x_not_dyn = std::all_of(x_shp.begin(), x_shp.end(), [](int64_t value) { return value != Shape::SHP_ANY; }); diff --git a/mindspore/core/ir/meta_tensor.cc b/mindspore/core/ir/meta_tensor.cc index c33d7291269..4c1991d7954 100644 --- a/mindspore/core/ir/meta_tensor.cc +++ b/mindspore/core/ir/meta_tensor.cc @@ -61,8 +61,8 @@ bool MetaTensor::operator==(const MetaTensor &meta_tensor) const { // The given index number should be in [0, shape_.size()). // param index Dimension index number. // return The size of the dimension if succeed, or -1 if failed. -int MetaTensor::DimensionSize(const size_t index) const { - int dim_size = -1; +int64_t MetaTensor::DimensionSize(const size_t index) const { + int64_t dim_size = -1; if (index < shape_.size()) { dim_size = shape_[index]; } else { @@ -71,9 +71,7 @@ int MetaTensor::DimensionSize(const size_t index) const { return dim_size; } -int MetaTensor::ElementsNum() const { - return std::accumulate(shape_.begin(), shape_.end(), 1LL, std::multiplies()); -} +int MetaTensor::ElementsNum() const { return std::accumulate(shape_.begin(), shape_.end(), 1, std::multiplies()); } TypePtr MetaTensor::SetDtype(const TypePtr type_ptr) { if (type_ptr == nullptr) { diff --git a/mindspore/core/ir/meta_tensor.h b/mindspore/core/ir/meta_tensor.h index 0b89a6f1096..f542baca869 100644 --- a/mindspore/core/ir/meta_tensor.h +++ b/mindspore/core/ir/meta_tensor.h @@ -144,7 +144,7 @@ class MetaTensor : public Value { const std::string &host_format = "DefaultFormat"); // Get the size of a given dimension by its index number. - int DimensionSize(size_t index) const; + int64_t DimensionSize(size_t index) const; // Get total number of elements in a tensor. int ElementsNum() const; diff --git a/mindspore/core/utils/check_convert_utils.cc b/mindspore/core/utils/check_convert_utils.cc index d02d5eb5d3d..613501b40d0 100644 --- a/mindspore/core/utils/check_convert_utils.cc +++ b/mindspore/core/utils/check_convert_utils.cc @@ -413,9 +413,8 @@ abstract::ShapePtr CheckAndConvertUtils::GetTensorInputShape(const std::string & return shape; } -void CheckAndConvertUtils::Check(const string &arg_name, int64_t arg_value, CompareEnum compare_type, - const string &value_name, int64_t value, const string &prim_name, - ExceptionType exception_type) { +void CheckAndConvertUtils::Check(const string &arg_name, int64_t arg_value, CompareEnum compare_type, const string &, + int64_t value, const string &prim_name, ExceptionType exception_type) { auto iter = kCompareMap.find(compare_type); if (iter == kCompareMap.end()) { MS_EXCEPTION(NotExistsError) << "the compare type :" << compare_type << " is not in the compare map";