From 92d49e1f59c0c4b2bd3d67645c222b7445166648 Mon Sep 17 00:00:00 2001 From: Molly Sophia Date: Sun, 24 Dec 2023 17:37:55 +0800 Subject: [PATCH] requantize: Use activation_ss in fused_activation.h (#5245) Which fixes int8 requantization on risc-v Signed-off-by: Molly Sophia --- src/layer/requantize.cpp | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/layer/requantize.cpp b/src/layer/requantize.cpp index e11fbc6b272..f98e7a320c6 100644 --- a/src/layer/requantize.cpp +++ b/src/layer/requantize.cpp @@ -14,6 +14,7 @@ // specific language governing permissions and limitations under the License. #include "requantize.h" +#include "fused_activation.h" namespace ncnn { @@ -25,38 +26,6 @@ static inline signed char float2int8(float v) return (signed char)int32; } -static inline float activation_ss(float v, int activation_type, const ncnn::Mat& activation_params) -{ - if (activation_type == 1) - { - v = fmaxf(v, 0.f); - } - else if (activation_type == 2) - { - float slope = activation_params[0]; - v = v > 0.f ? v : v * slope; - } - else if (activation_type == 3) - { - float min = activation_params[0]; - float max = activation_params[1]; - if (v < min) - v = min; - if (v > max) - v = max; - } - else if (activation_type == 4) - { - v = 1.f / (1.f + expf(-v)); - } - else if (activation_type == 5) - { - v = v * tanhf(logf(expf(v) + 1.f)); - } - - return v; -} - Requantize::Requantize() { one_blob_only = true;