From fb59eeb4c240fcffc49355751fd4384211b0e861 Mon Sep 17 00:00:00 2001 From: nihuini Date: Fri, 20 Nov 2020 17:29:33 +0800 Subject: [PATCH] fix bias x86 sse2 code style --- src/layer/x86/bias_x86.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/layer/x86/bias_x86.cpp b/src/layer/x86/bias_x86.cpp index fe5942689..4dff0fcc3 100644 --- a/src/layer/x86/bias_x86.cpp +++ b/src/layer/x86/bias_x86.cpp @@ -11,13 +11,14 @@ // 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. + +#include "bias_x86.h" + #include #if __AVX__ #include #endif // __AVX__ -#include "bias_x86.h" - namespace ncnn { int Bias_x86::forward_inplace(Mat& bottom_top_blob, const Option& opt) const @@ -36,7 +37,6 @@ int Bias_x86::forward_inplace(Mat& bottom_top_blob, const Option& opt) const float bias = bias_ptr[q]; int i = 0; - __m128 _bias128; #if __AVX__ { __m256 _bias256 = _mm256_set1_ps(bias); @@ -48,16 +48,14 @@ int Bias_x86::forward_inplace(Mat& bottom_top_blob, const Option& opt) const ptr += 8; } - _bias128 = _mm256_castps256_ps128(_bias256); } -#else - _bias128 = _mm_set1_ps(bias); #endif // __AVX__ { + __m128 _bias = _mm_set1_ps(bias); for (; i + 3 < size; i += 4) { __m128 _p = _mm_loadu_ps(ptr); - __m128 _outp = _mm_add_ps(_p, _bias128); + __m128 _outp = _mm_add_ps(_p, _bias); _mm_storeu_ps(ptr, _outp); ptr += 4;