From 3f7cada769bb2664446adace5c5f299ef463aa61 Mon Sep 17 00:00:00 2001 From: zhaozhenlong Date: Wed, 2 Dec 2020 14:58:16 +0800 Subject: [PATCH] fix code check --- mindspore/lite/nnacl/adder.c | 18 ------------------ mindspore/lite/nnacl/fp32/crop_fp32.c | 8 ++++---- mindspore/lite/nnacl/int8/resize_int8.c | 6 ++++++ mindspore/lite/tools/net_train/net_train.cc | 3 +-- 4 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 mindspore/lite/nnacl/adder.c diff --git a/mindspore/lite/nnacl/adder.c b/mindspore/lite/nnacl/adder.c deleted file mode 100644 index 9d4db613f3..0000000000 --- a/mindspore/lite/nnacl/adder.c +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "nnacl/adder.h" -#include "nnacl/errorcode.h" diff --git a/mindspore/lite/nnacl/fp32/crop_fp32.c b/mindspore/lite/nnacl/fp32/crop_fp32.c index ea84d3f94c..5724e2531e 100644 --- a/mindspore/lite/nnacl/fp32/crop_fp32.c +++ b/mindspore/lite/nnacl/fp32/crop_fp32.c @@ -18,9 +18,9 @@ #include "nnacl/op_base.h" #include "nnacl/crop_parameter.h" -void Pad4DOffset(const CropParameter *crop_param, int64_t *offset) { +void Pad4DOffset(const CropParameter *crop_param, int64_t *offset, int length) { int axis = crop_param->axis_; - for (int i = DIMENSION_4D - 1; i >= 0; --i) { + for (int i = length - 1; i >= 0; --i) { int offset_index = i - axis; if (offset_index >= 0) { offset[i] = crop_param->offset_[offset_index]; @@ -33,7 +33,7 @@ void Pad4DOffset(const CropParameter *crop_param, int64_t *offset) { void Crop4D(const float *input, float *output, const int *in_shape, const int *out_shape, const CropParameter *crop_param, int thread_id) { int64_t offset_pad[DIMENSION_4D]; - Pad4DOffset(crop_param, offset_pad); + Pad4DOffset(crop_param, offset_pad, DIMENSION_4D); int out_shape1 = out_shape[1]; int out_shape2 = out_shape[2]; int out_shape3 = out_shape[3]; @@ -68,7 +68,7 @@ void Crop4D(const float *input, float *output, const int *in_shape, const int *o void Crop4DNoParallel(const float *input, float *output, const int *in_shape, const int *out_shape, const CropParameter *crop_param) { int64_t offset_pad[DIMENSION_4D]; - Pad4DOffset(crop_param, offset_pad); + Pad4DOffset(crop_param, offset_pad, DIMENSION_4D); size_t in_dim2_stride = in_shape[3]; size_t in_dim1_stride = in_shape[2] * in_dim2_stride; size_t in_dim0_stride = in_dim1_stride * in_shape[1]; diff --git a/mindspore/lite/nnacl/int8/resize_int8.c b/mindspore/lite/nnacl/int8/resize_int8.c index 7198fac124..228f70a40f 100644 --- a/mindspore/lite/nnacl/int8/resize_int8.c +++ b/mindspore/lite/nnacl/int8/resize_int8.c @@ -21,6 +21,9 @@ int ResizeBilinearInt8(const int8_t *input_ptr, int8_t *output_ptr, int batch, int in_h, int in_w, int out_h, int out_w, int channel, int index, int count, ResizeQuantArg quant_arg) { + if (out_w == 0) { + return NNACL_ERRCODE_DIVISOR_ZERO; + } int in_plane = in_h * in_w; int out_plane = out_h * out_w; for (int n = 0; n < batch; n++) { @@ -67,6 +70,9 @@ int ResizeBilinearInt8(const int8_t *input_ptr, int8_t *output_ptr, int batch, i int ResizeBilinearWithFloatScaleInt8(const int8_t *input_ptr, int8_t *output_ptr, int batch, int in_h, int in_w, int out_h, int out_w, int channel, int index, int count, ResizeFloatScaleQuantArg quant_arg) { + if (out_w == 0) { + return NNACL_ERRCODE_DIVISOR_ZERO; + } int in_plane = in_h * in_w; int out_plane = out_h * out_w; for (int n = 0; n < batch; n++) { diff --git a/mindspore/lite/tools/net_train/net_train.cc b/mindspore/lite/tools/net_train/net_train.cc index eb1356e97f..f667e5e983 100644 --- a/mindspore/lite/tools/net_train/net_train.cc +++ b/mindspore/lite/tools/net_train/net_train.cc @@ -524,9 +524,8 @@ void NetTrainFlags::InitInputDataList() { char *saveptr1 = nullptr; char *input_list = new char[this->in_data_file_.length() + 1]; snprintf(input_list, this->in_data_file_.length() + 1, "%s", this->in_data_file_.c_str()); - char *cur_input; const char *split_c = ","; - cur_input = strtok_r(input_list, split_c, &saveptr1); + char *cur_input = strtok_r(input_list, split_c, &saveptr1); while (cur_input != nullptr) { input_data_list_.emplace_back(cur_input); cur_input = strtok_r(nullptr, split_c, &saveptr1);