From a17eb3b767ef2b8f6df9830755f3a781e1bca8f1 Mon Sep 17 00:00:00 2001 From: lixian Date: Fri, 12 Mar 2021 19:42:22 +0800 Subject: [PATCH] fix mirror padding float abortion --- .../lite/src/runtime/kernel/arm/fp16/pad_fp16.cc | 8 +++++++- .../lite/src/runtime/kernel/arm/fp32/pad_fp32.cc | 14 +++++++++----- .../lite/src/runtime/kernel/arm/int8/pad_int8.cc | 6 +++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/pad_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/pad_fp16.cc index 3665dbaab8..3da2a1ed7a 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/pad_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/pad_fp16.cc @@ -66,7 +66,13 @@ int PadFp16CPUKernel::Run() { MS_LOG(ERROR) << "BatchnormRun error error_code[" << ret << "]"; } } else { - HandleMirrorPad(); + // mirror pad case + ret = HandleMirrorPad(); + if (ret != RET_OK) { + MS_LOG(ERROR) << "Handle mirror pad failed, error_code[" << ret << "]"; + return ret; + } + ret = ParallelLaunch(this->context_->thread_pool_, MirrorPadImpl, this, context_->thread_num_); if (ret != RET_OK) { MS_LOG(ERROR) << "Pad Reflect or Symmetric mode run error, error_code[" << ret << "]"; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/pad_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/pad_fp32.cc index ecba2a4952..ec51c8b047 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/pad_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/pad_fp32.cc @@ -299,12 +299,12 @@ int PadCPUKernel::CheckPaddings(int *paddings, int length, int *input_shape, int for (auto i = 0; i < length; ++i) { int max_valid = input_shape[i] - offset; if (paddings[i * 2] > max_valid) { - MS_LOG(ERROR) << prefix << "paddings " << paddings[i * 2] << "should be less than " << max_valid + 1; - return RET_ERROR; + MS_LOG(WARNING) << prefix << "paddings " << paddings[i * 2] << " should be less than " << max_valid + 1; + MS_LOG(WARNING) << "Running mirror pad with padding bigger than shape."; } if (paddings[i * 2 + 1] > max_valid) { - MS_LOG(ERROR) << prefix << "paddings " << paddings[i * 2 + 1] << "should be less than " << max_valid + 1; - return RET_ERROR; + MS_LOG(WARNING) << prefix << "paddings " << paddings[i * 2 + 1] << " should be less than " << max_valid + 1; + MS_LOG(WARNING) << "Running mirror pad with padding bigger than shape."; } } return RET_OK; @@ -402,7 +402,11 @@ int PadCPUKernel::Run() { } } else { // mirror pad case - HandleMirrorPad(); + error_code = HandleMirrorPad(); + if (error_code != RET_OK) { + MS_LOG(ERROR) << "Handle mirror pad failed, error_code[" << error_code << "]"; + return error_code; + } error_code = ParallelLaunch(this->context_->thread_pool_, MirrorPadImpl, this, context_->thread_num_); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc index 03788425b0..2195640e9f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc @@ -274,7 +274,11 @@ int PadInt8CPUKernel::Run() { } } else { // mirror pad case - HandleMirrorPad(); + error_code = HandleMirrorPad(); + if (error_code != RET_OK) { + MS_LOG(ERROR) << "Handle mirror pad failed, error_code[" << error_code << "]"; + return error_code; + } error_code = ParallelLaunch(this->context_->thread_pool_, MirrorPadImplInt8, this, context_->thread_num_); if (error_code != RET_OK) {