From 36240ec7e3d6c566fe4a232cc7c1439e18e37610 Mon Sep 17 00:00:00 2001 From: ling Date: Wed, 26 Aug 2020 10:52:10 +0800 Subject: [PATCH] [MS][LITE][Develop]pooling arm32 build --- mindspore/lite/nnacl/fp32/pooling.c | 3 +- mindspore/lite/nnacl/{ => fp32}/scale.c | 6 ++-- mindspore/lite/nnacl/fp32/scale.h | 30 +++++++++++++++++++ mindspore/lite/nnacl/scale.h | 9 ------ .../lite/src/runtime/kernel/arm/fp32/scale.h | 2 +- 5 files changed, 35 insertions(+), 15 deletions(-) rename mindspore/lite/nnacl/{ => fp32}/scale.c (97%) create mode 100644 mindspore/lite/nnacl/fp32/scale.h diff --git a/mindspore/lite/nnacl/fp32/pooling.c b/mindspore/lite/nnacl/fp32/pooling.c index a7d56281d3..a0b6db9aea 100644 --- a/mindspore/lite/nnacl/fp32/pooling.c +++ b/mindspore/lite/nnacl/fp32/pooling.c @@ -488,8 +488,7 @@ void AvgPoolingRelu6(const float *input_ptr, float *output_ptr, PoolingParameter } // win_w loop } // win_h loop #ifdef ENABLE_NEON - float32x4_t count = vdupq_n_f32(real_count); - tmp_avg = vdivq_f32(tmp_avg, count); + tmp_avg = tmp_avg / vdupq_n_f32(real_count); tmp_avg = vmaxq_f32(tmp_avg, zeros); tmp_avg = vminq_f32(tmp_avg, bounds); vst1q_f32(output_ptr + out_channel_offset, tmp_avg); diff --git a/mindspore/lite/nnacl/scale.c b/mindspore/lite/nnacl/fp32/scale.c similarity index 97% rename from mindspore/lite/nnacl/scale.c rename to mindspore/lite/nnacl/fp32/scale.c index e5411e77c4..0806999f80 100644 --- a/mindspore/lite/nnacl/scale.c +++ b/mindspore/lite/nnacl/fp32/scale.c @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "nnacl/scale.h" +#include "nnacl/fp32/scale.h" #ifdef ENABLE_ARM #include #endif @@ -25,7 +25,7 @@ void ScaleInner(float *in_data, float *out_data, float *scale, float *offset, in for (int i = 0; i < axis_size; i++) { int axis_offset = out_offset + i * inner_size; int in_index = 0; -#ifdef ENABLE_ARM +#ifdef ENABLE_ARM64 for (; in_index < inner_size - 4; in_index += 4) { int in_offset = axis_offset + in_index; float32x4_t data = vld1q_f32(in_data + in_offset); @@ -48,7 +48,7 @@ void ScaleAxis(float *in_data, float *out_data, float *scale, float *offset, int for (int out = outer_start; out < outer_end; out++) { int out_offset = out * axis_size; int index = 0; -#ifdef ENABLE_ARM +#ifdef ENABLE_ARM64 for (; index < axis_size - 4; index += 4) { int in_offset = out_offset + index; float32x4_t data = vld1q_f32(in_data + in_offset); diff --git a/mindspore/lite/nnacl/fp32/scale.h b/mindspore/lite/nnacl/fp32/scale.h new file mode 100644 index 0000000000..63ba1dd200 --- /dev/null +++ b/mindspore/lite/nnacl/fp32/scale.h @@ -0,0 +1,30 @@ +/** + * 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. + */ + +#ifndef MINDSPORE_LITE_NNACL_SCALE_FP32_H_ +#define MINDSPORE_LITE_NNACL_SCALE_FP32_H_ + +#include "nnacl/op_base.h" +#include "nnacl/scale.h" +#ifdef __cplusplus +extern "C" { +#endif +void DoScale(float *in_data, float *out_data, float *scale, float *offset, int task_id, ScaleParameter *scale_param); +#ifdef __cplusplus +} +#endif + +#endif // MINDSPORE_LITE_NNACL_SCALE_FP32_H_ diff --git a/mindspore/lite/nnacl/scale.h b/mindspore/lite/nnacl/scale.h index 680ecd173e..83244eb146 100644 --- a/mindspore/lite/nnacl/scale.h +++ b/mindspore/lite/nnacl/scale.h @@ -18,7 +18,6 @@ #define MINDSPORE_LITE_NNACL_SCALE_H_ #include "nnacl/op_base.h" - typedef struct ScaleParameter { OpParameter op_parameter_; int outer_size_; @@ -28,12 +27,4 @@ typedef struct ScaleParameter { bool const_scale_; } ScaleParameter; -#ifdef __cplusplus -extern "C" { -#endif -void DoScale(float *in_data, float *out_data, float *scale, float *offset, int task_id, ScaleParameter *scale_param); -#ifdef __cplusplus -} -#endif - #endif // MINDSPORE_LITE_NNACL_SCALE_H_ diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/scale.h b/mindspore/lite/src/runtime/kernel/arm/fp32/scale.h index 5125e17f1b..8071f16bdd 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/scale.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/scale.h @@ -19,7 +19,7 @@ #include #include "src/lite_kernel.h" -#include "nnacl/scale.h" +#include "nnacl/fp32/scale.h" namespace mindspore::kernel {