diff --git a/mindspore/lite/src/ops/tile.cc b/mindspore/lite/src/ops/tile.cc index aa142c8e24..4c27c6a2e8 100644 --- a/mindspore/lite/src/ops/tile.cc +++ b/mindspore/lite/src/ops/tile.cc @@ -186,7 +186,8 @@ int Tile::InferShape(std::vector inputs_, std::vector output out_shape.push_back(input->shape().at(i)); } for (size_t i = 0; i < dims.size(); ++i) { - if (multiples.at(i) > std::numeric_limits::max() / input->shape().at(dims.at(i))) { + if (input->shape().at(dims.at(i)) != 0 && + multiples.at(i) > std::numeric_limits::max() / input->shape().at(dims.at(i))) { MS_LOG(ERROR) << "The value of multiples[" << i << "] is too big"; return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.cc index 65f944d73b..d738f725dc 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.cc @@ -44,7 +44,7 @@ int AddNCPUKernel::ReSize() { return RET_OK; } int AddNCPUKernel::AddNParallelRun(int thread_id) { int count_per_thread = UP_DIV(elements_num_, op_parameter_->thread_num_); - int count = MSMIN(count_per_thread, static_cast(elements_num_ - thread_id * count_per_thread)); + int count = MSMIN(count_per_thread, elements_num_ - thread_id * count_per_thread); auto stride = count_per_thread * thread_id; auto ret = ElementAdd(in1_addr_ + stride, in2_addr_ + stride, out_addr_ + stride, count); if (ret != NNACL_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.h index 60a2b303e9..6d80376045 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.h @@ -39,7 +39,7 @@ class AddNCPUKernel : public LiteKernel { float *in1_addr_; float *in2_addr_; float *out_addr_; - size_t elements_num_; + int elements_num_; }; } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.cc index 1331f9691b..8fe3d6fc13 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.cc @@ -121,19 +121,15 @@ int CropAndResizeCPUKernel::RunImpl(int task_id) { int unit = UP_DIV(new_height_, context_->thread_num_); int h_begin = unit * task_id; int h_end = MSMIN(h_begin + unit, new_height_); + if (h_end <= h_begin) { + return RET_OK; + } int c = in_tensors_.at(0)->shape().at(3); float *line0 = line_buffer_ + new_width_ * c * 2 * task_id; float *line1 = line0 + new_width_ * c; - int ret = 0; - if (is_crop_) { - ret = CropAndResizeBilinear(input_data, output_data, input_shape.data(), out_tensors_.at(0)->shape().data(), - y_bottoms_, y_tops_, x_lefts_, x_rights_, y_bottom_weights_, x_left_weights_, line0, - line1, h_begin, h_end); - } else { - ret = - ResizeBilinear(input_data, output_data, input_shape.data(), out_tensors_.at(0)->shape().data(), y_bottoms_, - y_tops_, x_lefts_, x_rights_, y_bottom_weights_, x_left_weights_, line0, line1, h_begin, h_end); - } + auto ret = CropAndResizeBilinear(input_data, output_data, input_shape.data(), out_tensors_.at(0)->shape().data(), + y_bottoms_, y_tops_, x_lefts_, x_rights_, y_bottom_weights_, x_left_weights_, line0, + line1, h_begin, h_end); return ret; } @@ -146,19 +142,10 @@ int CropAndResizeCPUKernel::Run() { auto input = in_tensors_.at(0); auto input_shape = input->shape(); - // if boxes tensor data is nullptr, crop_and_resize can be seen as resize with coordinate transformation mode - // ALIGN_CORNERS - if (in_tensors_.at(1)->ElementsNum() == 0 || in_tensors_.at(1)->data_c() == nullptr) { - batch_ = 1; - is_crop_ = false; - ret = PrepareResizeBilinear(input_shape.data(), out_tensors_.at(0)->shape().data(), CalculateAlignCorners, - y_bottoms_, y_tops_, x_lefts_, x_rights_, y_bottom_weights_, x_left_weights_); - } else { - auto boxes = reinterpret_cast(in_tensors_.at(1)->data_c()); - auto box_idx = reinterpret_cast(in_tensors_.at(2)->data_c()); - ret = PrepareCropAndResizeBilinear(input_shape.data(), boxes, box_idx, out_tensors_.at(0)->shape().data(), - y_bottoms_, y_tops_, x_lefts_, x_rights_, y_bottom_weights_, x_left_weights_); - } + auto boxes = reinterpret_cast(in_tensors_.at(1)->data_c()); + auto box_idx = reinterpret_cast(in_tensors_.at(2)->data_c()); + ret = PrepareCropAndResizeBilinear(input_shape.data(), boxes, box_idx, out_tensors_.at(0)->shape().data(), y_bottoms_, + y_tops_, x_lefts_, x_rights_, y_bottom_weights_, x_left_weights_); if (ret != RET_OK) { FreeTmpBuffer(); return ret; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.h index 9619724841..50bf38c7c3 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.h @@ -46,7 +46,6 @@ class CropAndResizeCPUKernel : public LiteKernel { int batch_; int new_height_; int new_width_; - bool is_crop_ = true; int *y_tops_ = nullptr; int *y_bottoms_ = nullptr; int *x_lefts_ = nullptr; diff --git a/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg b/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg index 2d1251765a..9d07af305c 100644 --- a/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg +++ b/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg @@ -37,3 +37,4 @@ ml_video_edit_video_segment_gauss_adaptis_part2.pb;2 ml_video_edit_video_segment_gauss_adaptis_part2_pb2tflite.tflite;2 tiny-yolov3-11.onnx;2;1,416,416,3:1,2 ml_video_edit_person_divison_pic;2 +fasterrcnn_crop.pb;1;236,190,3