From 0ac2f0e04ce014caa7d7a7f0076e561ece90eacf Mon Sep 17 00:00:00 2001 From: Sinitsina Date: Wed, 22 Jul 2020 21:26:27 +0300 Subject: [PATCH] mish_functor_update --- modules/dnn/src/layers/elementwise_layers.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/dnn/src/layers/elementwise_layers.cpp b/modules/dnn/src/layers/elementwise_layers.cpp index 1bd8abef87..d53393c3e0 100644 --- a/modules/dnn/src/layers/elementwise_layers.cpp +++ b/modules/dnn/src/layers/elementwise_layers.cpp @@ -669,9 +669,14 @@ struct MishFunctor : public BaseFunctor { // Use fast approximation introduced in https://github.com/opencv/opencv/pull/17200 float x = srcptr[i]; - float eX = exp(std::min(x, 20.f)); - float n = (eX + 2) * eX; - dstptr[i] = (x * n) / (n + 2); + if (x >= 8.f) + dstptr[i] = x; + else + { + float eX = exp(x); + float n = (eX + 2) * eX; + dstptr[i] = (x * n) / (n + 2); + } } } }