Browse Source

fix thread problem

tags/v1.2.0-rc1
yeyunpeng 4 years ago
parent
commit
bfef5cda2b
6 changed files with 15 additions and 27 deletions
  1. +2
    -1
      mindspore/lite/src/ops/tile.cc
  2. +1
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.cc
  3. +1
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.h
  4. +10
    -23
      mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.cc
  5. +0
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.h
  6. +1
    -0
      mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg

+ 2
- 1
mindspore/lite/src/ops/tile.cc View File

@@ -186,7 +186,8 @@ int Tile::InferShape(std::vector<Tensor *> inputs_, std::vector<Tensor *> output
out_shape.push_back(input->shape().at(i)); out_shape.push_back(input->shape().at(i));
} }
for (size_t i = 0; i < dims.size(); ++i) { for (size_t i = 0; i < dims.size(); ++i) {
if (multiples.at(i) > std::numeric_limits<int>::max() / input->shape().at(dims.at(i))) {
if (input->shape().at(dims.at(i)) != 0 &&
multiples.at(i) > std::numeric_limits<int>::max() / input->shape().at(dims.at(i))) {
MS_LOG(ERROR) << "The value of multiples[" << i << "] is too big"; MS_LOG(ERROR) << "The value of multiples[" << i << "] is too big";
return RET_ERROR; return RET_ERROR;
} }


+ 1
- 1
mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.cc View File

@@ -44,7 +44,7 @@ int AddNCPUKernel::ReSize() { return RET_OK; }


int AddNCPUKernel::AddNParallelRun(int thread_id) { int AddNCPUKernel::AddNParallelRun(int thread_id) {
int count_per_thread = UP_DIV(elements_num_, op_parameter_->thread_num_); int count_per_thread = UP_DIV(elements_num_, op_parameter_->thread_num_);
int count = MSMIN(count_per_thread, static_cast<int>(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 stride = count_per_thread * thread_id;
auto ret = ElementAdd(in1_addr_ + stride, in2_addr_ + stride, out_addr_ + stride, count); auto ret = ElementAdd(in1_addr_ + stride, in2_addr_ + stride, out_addr_ + stride, count);
if (ret != NNACL_OK) { if (ret != NNACL_OK) {


+ 1
- 1
mindspore/lite/src/runtime/kernel/arm/fp32/addn_fp32.h View File

@@ -39,7 +39,7 @@ class AddNCPUKernel : public LiteKernel {
float *in1_addr_; float *in1_addr_;
float *in2_addr_; float *in2_addr_;
float *out_addr_; float *out_addr_;
size_t elements_num_;
int elements_num_;
}; };
} // namespace mindspore::kernel } // namespace mindspore::kernel




+ 10
- 23
mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.cc View File

@@ -121,19 +121,15 @@ int CropAndResizeCPUKernel::RunImpl(int task_id) {
int unit = UP_DIV(new_height_, context_->thread_num_); int unit = UP_DIV(new_height_, context_->thread_num_);
int h_begin = unit * task_id; int h_begin = unit * task_id;
int h_end = MSMIN(h_begin + unit, new_height_); 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); int c = in_tensors_.at(0)->shape().at(3);
float *line0 = line_buffer_ + new_width_ * c * 2 * task_id; float *line0 = line_buffer_ + new_width_ * c * 2 * task_id;
float *line1 = line0 + new_width_ * c; 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; return ret;
} }


@@ -146,19 +142,10 @@ int CropAndResizeCPUKernel::Run() {


auto input = in_tensors_.at(0); auto input = in_tensors_.at(0);
auto input_shape = input->shape(); 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<float *>(in_tensors_.at(1)->data_c());
auto box_idx = reinterpret_cast<int32_t *>(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<float *>(in_tensors_.at(1)->data_c());
auto box_idx = reinterpret_cast<int32_t *>(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) { if (ret != RET_OK) {
FreeTmpBuffer(); FreeTmpBuffer();
return ret; return ret;


+ 0
- 1
mindspore/lite/src/runtime/kernel/arm/fp32/crop_and_resize_fp32.h View File

@@ -46,7 +46,6 @@ class CropAndResizeCPUKernel : public LiteKernel {
int batch_; int batch_;
int new_height_; int new_height_;
int new_width_; int new_width_;
bool is_crop_ = true;
int *y_tops_ = nullptr; int *y_tops_ = nullptr;
int *y_bottoms_ = nullptr; int *y_bottoms_ = nullptr;
int *x_lefts_ = nullptr; int *x_lefts_ = nullptr;


+ 1
- 0
mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg View File

@@ -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 ml_video_edit_video_segment_gauss_adaptis_part2_pb2tflite.tflite;2
tiny-yolov3-11.onnx;2;1,416,416,3:1,2 tiny-yolov3-11.onnx;2;1,416,416,3:1,2
ml_video_edit_person_divison_pic;2 ml_video_edit_person_divison_pic;2
fasterrcnn_crop.pb;1;236,190,3

Loading…
Cancel
Save