mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
Optimize Mish for CPU backend
This commit is contained in:
parent
fce486c4f9
commit
1491934d17
@ -667,8 +667,11 @@ struct MishFunctor : public BaseFunctor
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
// Use fast approximation introduced in https://github.com/opencv/opencv/pull/17200
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = x * tanh(log(1.0f + exp(x)));
|
||||
float eX = exp(std::min(x, 20.f));
|
||||
float n = (eX + 2) * eX;
|
||||
dstptr[i] = (x * n) / (n + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user