From 8cafcd9d8372c83a66f833f335d8795fbc5b03ea Mon Sep 17 00:00:00 2001 From: z00512249 Date: Fri, 30 Apr 2021 11:36:37 +0800 Subject: [PATCH] fix micro coder codex --- .../opcoders/nnacl/fp32/arithmetic_fp32_coder.cc | 6 +++++- .../coder/opcoders/nnacl/int8/add_int8_coder.h | 2 +- .../coder/opcoders/nnacl/int8/div_int8_coder.cc | 2 +- .../coder/opcoders/nnacl/int8/div_int8_coder.h | 2 +- .../coder/opcoders/nnacl/int8/relux_int8_coder.h | 4 ++-- .../opcoders/nnacl/int8/resize_int8_coder.cc | 12 ++++++++++-- .../coder/opcoders/nnacl/int8/resize_int8_coder.h | 15 +-------------- .../coder/opcoders/nnacl/int8/sub_int8_coder.h | 2 +- .../wrapper/int8/conv1x1_init_int8_wrapper.c | 1 - 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/arithmetic_fp32_coder.cc b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/arithmetic_fp32_coder.cc index e361d0c0c91..fc6c504c0f7 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/arithmetic_fp32_coder.cc +++ b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/arithmetic_fp32_coder.cc @@ -93,7 +93,11 @@ int ArithmeticFP32Coder::ReSize(CoderContext *const context) { CalcMultiplesAndStrides(arithmetic_parameter_); if (arithmetic_parameter_->broadcasting_) { outside_ = 1; - for (auto i = arithmetic_parameter_->ndim_ - 1; i >= 0; --i) { + int resize_n_index = static_cast(arithmetic_parameter_->ndim_) - 1; + if (resize_n_index < 0) { + return RET_ERROR; + } + for (auto i = resize_n_index; i >= 0; --i) { if (arithmetic_parameter_->in_shape0_[i] != arithmetic_parameter_->in_shape1_[i]) { break_pos_ = i; break; diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/int8/add_int8_coder.h b/mindspore/lite/micro/coder/opcoders/nnacl/int8/add_int8_coder.h index 27eb507c8ed..d6c4d6415fd 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/int8/add_int8_coder.h +++ b/mindspore/lite/micro/coder/opcoders/nnacl/int8/add_int8_coder.h @@ -38,7 +38,7 @@ class AddInt8Coder final : public OperatorCoder { int Init(); int ReSize(); - AddQuantParameter para_; + AddQuantParameter para_{}; ArithmeticParameter *arith_para_{nullptr}; Tensor *input0{nullptr}; Tensor *input1{nullptr}; diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.cc b/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.cc index cbcf4530ae9..0b362edbf00 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.cc +++ b/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.cc @@ -54,7 +54,7 @@ int DivInt8Coder::DoCode(CoderContext *const context) { int element_num = output_tensor_->ElementsNum(); code.CodeStruct("param", param_); if (broadcast_) { - ArithmeticParameter tile_para; + ArithmeticParameter tile_para = {0}; tile_para.ndim_ = output_tensor_->shape().size(); for (size_t i = 0; i < tile_para.ndim_; i++) { tile_para.in_shape0_[i] = input0->DimensionSize(i); diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.h b/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.h index d648f040a7f..ceccad806bf 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.h +++ b/mindspore/lite/micro/coder/opcoders/nnacl/int8/div_int8_coder.h @@ -37,7 +37,7 @@ class DivInt8Coder final : public OperatorCoder { int DoCode(CoderContext *const context) override; private: - DivQuantArg param_; + DivQuantArg param_{}; Tensor *input0{nullptr}; Tensor *input1{nullptr}; int8_t *tile0_data_{nullptr}; diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/int8/relux_int8_coder.h b/mindspore/lite/micro/coder/opcoders/nnacl/int8/relux_int8_coder.h index ff55311dfb3..f42db86a037 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/int8/relux_int8_coder.h +++ b/mindspore/lite/micro/coder/opcoders/nnacl/int8/relux_int8_coder.h @@ -39,10 +39,10 @@ class ReluxInt8Coder : public OperatorCoder { int DoCode(CoderContext *const context) override; protected: - ReluXQuantArg quant_arg_; + ReluXQuantArg quant_arg_{}; private: - int type_; + int type_{0}; }; class ReluInt8Coder final : public ReluxInt8Coder { diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.cc b/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.cc index ee109cc5448..3a986050daa 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.cc +++ b/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.cc @@ -40,8 +40,16 @@ int ResizeInt8Coder::Prepare(CoderContext *const context) { quant_out_ = new (std::nothrow)::QuantArg; multiplier_ = new (std::nothrow) QuantMulArg; MS_CHECK_PTR(quant_in_); - MS_CHECK_PTR(quant_out_); - MS_CHECK_PTR(multiplier_); + if (quant_out_ == nullptr) { + delete quant_in_; + quant_in_ = nullptr; + } + if (multiplier_ == nullptr) { + delete quant_in_; + quant_in_ = nullptr; + delete quant_out_; + quant_out_ = nullptr; + } quant_in_->zp_ = input_tensor_->quant_params().at(0).zeroPoint; quant_in_->scale_ = input_tensor_->quant_params().at(0).scale; quant_out_->zp_ = output_tensor_->quant_params().at(0).zeroPoint; diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.h b/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.h index ca849dfc581..19d3c4082cd 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.h +++ b/mindspore/lite/micro/coder/opcoders/nnacl/int8/resize_int8_coder.h @@ -29,7 +29,7 @@ class ResizeInt8Coder final : public ResizeBaseCoder { const Model::Node *node, size_t node_index, Target target) : ResizeBaseCoder(in_tensors, out_tensors, node, node_index, target) {} - ~ResizeInt8Coder(); + ~ResizeInt8Coder() override; int Prepare(CoderContext *const context) override; @@ -37,23 +37,10 @@ class ResizeInt8Coder final : public ResizeBaseCoder { private: int ReSize(); - int InitResizeBiLinear(); - int InitFloatResizeBiLinear(); - int InitResizeQuantArg(); - int CalRatio(); - int CalInterpolationRange(); - void FreeResizeBiLinear(); - int InitResizeFloatQuantArg(); - int CalFloatRatio(); - int CalFloatInterpolationRange(); - void FreeFloatResizeBiLinear(); - ResizeParameter *param_{nullptr}; ::QuantArg *quant_in_{nullptr}; ::QuantArg *quant_out_{nullptr}; QuantMulArg *multiplier_{nullptr}; - ResizeQuantArg resize_quant_arg_; - ResizeFloatScaleQuantArg resize_float_quant_arg_; }; } // namespace mindspore::lite::micro::nnacl diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/int8/sub_int8_coder.h b/mindspore/lite/micro/coder/opcoders/nnacl/int8/sub_int8_coder.h index aab1adf59f2..fa34895bc57 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/int8/sub_int8_coder.h +++ b/mindspore/lite/micro/coder/opcoders/nnacl/int8/sub_int8_coder.h @@ -37,7 +37,7 @@ class SubInt8Coder final : public OperatorCoder { int DoCode(CoderContext *const context) override; private: - SubQuantArg param_; + SubQuantArg param_{}; Tensor *input0{nullptr}; Tensor *input1{nullptr}; int8_t *tile0_data_{nullptr}; diff --git a/mindspore/lite/micro/coder/wrapper/int8/conv1x1_init_int8_wrapper.c b/mindspore/lite/micro/coder/wrapper/int8/conv1x1_init_int8_wrapper.c index 5f30d4bd104..959d03a8a34 100644 --- a/mindspore/lite/micro/coder/wrapper/int8/conv1x1_init_int8_wrapper.c +++ b/mindspore/lite/micro/coder/wrapper/int8/conv1x1_init_int8_wrapper.c @@ -15,7 +15,6 @@ */ #include "wrapper/int8/conv1x1_init_int8_wrapper.h" -#include #include "nnacl/int8/matmul_int8.h" #include "nnacl/errorcode.h"