Skip to content

Commit

Permalink
Merge pull request opencv#17916 from SinM9:mish_functor_sin
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Jul 28, 2020
2 parents 6697f0e + 0ac2f0e commit e4d573a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/dnn/src/layers/elementwise_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit e4d573a

Please sign in to comment.