forked from huawei/mindspore2022
!17165 pclint clean
From: @zhangzhaoju Reviewed-by: @ginfung,@zh_qh Signed-off-by: @zh_qh
This commit is contained in:
commit
31e608bcd9
|
|
@ -293,7 +293,7 @@ class ZeroLikeFillZero : public AnfVisitor {
|
|||
}
|
||||
|
||||
tensor::TensorPtr new_tensor_ptr = std::make_shared<tensor::Tensor>(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<char *>(new_tensor_ptr->data_c());
|
||||
(void)memset_s(data, mem_size, 0, mem_size);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -428,7 +428,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()}});
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +465,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ AbstractBasePtr InferImplReduceFunc(const AnalysisEnginePtr &, const PrimitivePt
|
|||
return std::make_shared<AbstractTensor>(input_x->element(), std::make_shared<Shape>(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;
|
||||
|
|
@ -340,8 +340,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; });
|
||||
|
|
@ -398,8 +398,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; });
|
||||
|
|
|
|||
|
|
@ -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>());
|
||||
}
|
||||
int MetaTensor::ElementsNum() const { return std::accumulate(shape_.begin(), shape_.end(), 1, std::multiplies<int>()); }
|
||||
|
||||
TypePtr MetaTensor::SetDtype(const TypePtr type_ptr) {
|
||||
if (type_ptr == nullptr) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<float>.find(compare_type);
|
||||
if (iter == kCompareMap<float>.end()) {
|
||||
MS_EXCEPTION(NotExistsError) << "the compare type :" << compare_type << " is not in the compare map";
|
||||
|
|
|
|||
Loading…
Reference in New Issue