From 57bedd59fa05deaf27eb26e92503c9bc5d36962e Mon Sep 17 00:00:00 2001 From: nihui Date: Tue, 25 Feb 2020 21:16:12 +0800 Subject: [PATCH] fix build without neon --- src/layer/arm/convolution_arm.cpp | 23 +++++++++++++++++++- src/layer/arm/deconvolution_arm.cpp | 23 +++++++++++++++++++- src/layer/arm/deconvolutiondepthwise_arm.cpp | 23 +++++++++++++++++++- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/layer/arm/convolution_arm.cpp b/src/layer/arm/convolution_arm.cpp index 019c61b1e..1d4afb676 100644 --- a/src/layer/arm/convolution_arm.cpp +++ b/src/layer/arm/convolution_arm.cpp @@ -974,7 +974,28 @@ int Convolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option kptr += maxk; } - sum = activation_ss(sum, activation_type, activation_params); + if (activation_type == 1) + { + sum = std::max(sum, 0.f); + } + else if (activation_type == 2) + { + float slope = activation_params[0]; + sum = sum > 0.f ? sum : sum * slope; + } + else if (activation_type == 3) + { + float min = activation_params[0]; + float max = activation_params[1]; + if (sum < min) + sum = min; + if (sum > max) + sum = max; + } + else if (activation_type == 4) + { + sum = static_cast(1.f / (1.f + exp(-sum))); + } outptr[j] = sum; } diff --git a/src/layer/arm/deconvolution_arm.cpp b/src/layer/arm/deconvolution_arm.cpp index d1dcf9e70..c7a0f415b 100644 --- a/src/layer/arm/deconvolution_arm.cpp +++ b/src/layer/arm/deconvolution_arm.cpp @@ -644,7 +644,28 @@ int Deconvolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Opti kptr += maxk; } - sum = activation_ss(sum, activation_type, activation_params); + if (activation_type == 1) + { + sum = std::max(sum, 0.f); + } + else if (activation_type == 2) + { + float slope = activation_params[0]; + sum = sum > 0.f ? sum : sum * slope; + } + else if (activation_type == 3) + { + float min = activation_params[0]; + float max = activation_params[1]; + if (sum < min) + sum = min; + if (sum > max) + sum = max; + } + else if (activation_type == 4) + { + sum = static_cast(1.f / (1.f + exp(-sum))); + } outptr[j] = sum; } diff --git a/src/layer/arm/deconvolutiondepthwise_arm.cpp b/src/layer/arm/deconvolutiondepthwise_arm.cpp index 5ea194242..37310e78a 100644 --- a/src/layer/arm/deconvolutiondepthwise_arm.cpp +++ b/src/layer/arm/deconvolutiondepthwise_arm.cpp @@ -306,7 +306,28 @@ int DeconvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob, c } } - sum = activation_ss(sum, activation_type, activation_params); + if (activation_type == 1) + { + sum = std::max(sum, 0.f); + } + else if (activation_type == 2) + { + float slope = activation_params[0]; + sum = sum > 0.f ? sum : sum * slope; + } + else if (activation_type == 3) + { + float min = activation_params[0]; + float max = activation_params[1]; + if (sum < min) + sum = min; + if (sum > max) + sum = max; + } + else if (activation_type == 4) + { + sum = static_cast(1.f / (1.f + exp(-sum))); + } outptr[j] = sum; }