Skip to content

Commit e4d573a

Browse files
committed
Merge pull request opencv#17916 from SinM9:mish_functor_sin
2 parents 6697f0e + 0ac2f0e commit e4d573a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modules/dnn/src/layers/elementwise_layers.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,14 @@ struct MishFunctor : public BaseFunctor
669669
{
670670
// Use fast approximation introduced in https://github.com/opencv/opencv/pull/17200
671671
float x = srcptr[i];
672-
float eX = exp(std::min(x, 20.f));
673-
float n = (eX + 2) * eX;
674-
dstptr[i] = (x * n) / (n + 2);
672+
if (x >= 8.f)
673+
dstptr[i] = x;
674+
else
675+
{
676+
float eX = exp(x);
677+
float n = (eX + 2) * eX;
678+
dstptr[i] = (x * n) / (n + 2);
679+
}
675680
}
676681
}
677682
}

0 commit comments

Comments
 (0)