From a0fa047ed2122125c097f6f963ad6d68c6202e58 Mon Sep 17 00:00:00 2001 From: fuzhiye Date: Thu, 27 Aug 2020 14:38:25 +0800 Subject: [PATCH] fix resize --- .../runtime/kernel/arm/fp16/convolution_3x3_fp16.cc | 6 +++--- .../src/runtime/kernel/arm/fp16/convolution_fp16.cc | 10 +++++----- .../src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc | 6 +++--- .../kernel/arm/fp16/convolution_winograd_fp16.cc | 7 +++---- .../lite/src/runtime/kernel/arm/fp32/convolution.cc | 6 +++--- .../src/runtime/kernel/arm/fp32/convolution_3x3.cc | 6 +++--- .../runtime/kernel/arm/fp32/convolution_slidewindow.cc | 6 +++--- .../runtime/kernel/arm/fp32/convolution_winograd.cc | 7 +++---- .../runtime/kernel/arm/int8/convolution_3x3_int8.cc | 10 +++++----- .../src/runtime/kernel/arm/int8/convolution_int8.cc | 7 +++---- 10 files changed, 34 insertions(+), 37 deletions(-) diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc index c14710aed..99eef1760 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc @@ -142,14 +142,14 @@ void Convolution3x3FP16CPUKernel::ConfigInputOutput() { } int Convolution3x3FP16CPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc index 7aa6859a5..e229074f6 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc @@ -102,8 +102,8 @@ int ConvolutionFP16CPUKernel::InitTmpBuffer() { return RET_ERROR; } - size_t nhwc4_input_size = channel_block * C4NUM * in_batch * conv_param_->input_h_ * - conv_param_->input_w_ * sizeof(float16_t); + size_t nhwc4_input_size = + channel_block * C4NUM * in_batch * conv_param_->input_h_ * conv_param_->input_w_ * sizeof(float16_t); nhwc4_input_ = ctx_->allocator->Malloc(nhwc4_input_size); if (nhwc4_input_ == nullptr) { MS_LOG(ERROR) << "malloc nhwc4_input_ failed."; @@ -132,14 +132,14 @@ void ConvolutionFP16CPUKernel::ConfigInputOutput() { } int ConvolutionFP16CPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } ConfigInputOutput(); return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc index 27def2e8f..eb06a05c5 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc @@ -126,14 +126,14 @@ void ConvolutionSWFP16CPUKernel::ConfigInputOutput() { } int ConvolutionSWFP16CPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } ConfigInputOutput(); return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc index 834db8f80..6ec07a0b7 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc @@ -277,19 +277,18 @@ int ConvolutionWinogradFP16CPUKernel::ConfigInputOutput() { } int ConvolutionWinogradFP16CPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } kernel_unit_ = conv_param_->kernel_h_; input_unit_ = output_unit_ + kernel_unit_ - 1; conv_param_->input_unit_ = input_unit_; conv_param_->output_unit_ = output_unit_; - auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution.cc index e7af9e16d..c5252fdc4 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution.cc @@ -125,14 +125,14 @@ void ConvolutionCPUKernel::ConfigInputOutput() { } int ConvolutionCPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } ConfigInputOutput(); return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_3x3.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_3x3.cc index ba09d7404..a17a0853b 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_3x3.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_3x3.cc @@ -155,14 +155,14 @@ void Convolution3x3CPUKernel::ConfigInputOutput() { } int Convolution3x3CPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed.ret: " << ret; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } ConfigInputOutput(); return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_slidewindow.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_slidewindow.cc index 8489e8151..38a86cd63 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_slidewindow.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_slidewindow.cc @@ -96,14 +96,14 @@ void ConvolutionSWCPUKernel::ConfigInputOutput() { } int ConvolutionSWCPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } // config input output ConfigInputOutput(); return ReSize(); diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_winograd.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_winograd.cc index 8c009277b..40dcf4dd4 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_winograd.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_winograd.cc @@ -270,19 +270,18 @@ int ConvolutionWinogradCPUKernel::ConfigInputOutput() { } int ConvolutionWinogradCPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } kernel_unit_ = conv_param_->kernel_h_; input_unit_ = output_unit_ + kernel_unit_ - 1; conv_param_->input_unit_ = input_unit_; conv_param_->output_unit_ = output_unit_; - auto ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } + if (!InferShapeDone()) { + return RET_OK; + } return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_3x3_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_3x3_int8.cc index 3054d22ed..188ec44d6 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_3x3_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_3x3_int8.cc @@ -154,9 +154,8 @@ void Convolution3x3Int8CPUKernel::ConfigInputOutput() { } int Convolution3x3Int8CPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } + // config input output + ConfigInputOutput(); auto ret = SetQuantParam(); if (ret != RET_OK) { MS_LOG(ERROR) << "Set quant param failed."; @@ -167,8 +166,9 @@ int Convolution3x3Int8CPUKernel::Init() { MS_LOG(ERROR) << "Init weight bias failed."; return RET_ERROR; } - // config input output - ConfigInputOutput(); + if (!InferShapeDone()) { + return RET_OK; + } return ReSize(); } diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc index e3f670374..7b94444ae 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc @@ -247,9 +247,6 @@ void ConvolutionInt8CPUKernel::ConfigInputOutput() { } int ConvolutionInt8CPUKernel::Init() { - if (!InferShapeDone()) { - return RET_OK; - } // config input output ConfigInputOutput(); CheckSupportOptimize(); @@ -273,7 +270,9 @@ int ConvolutionInt8CPUKernel::Init() { return RET_ERROR; } } - + if (!InferShapeDone()) { + return RET_OK; + } return ReSize(); } -- GitLab