fix overflow

This commit is contained in:
fengyuentau 2023-06-23 17:10:29 +08:00
parent 4792837f2e
commit 29388f80a5

View File

@ -680,7 +680,14 @@ struct SigmoidFunctor : public BaseDefaultFunctor<SigmoidFunctor>
inline float calculate(float x) const
{
return 1.f / (1.f + exp(-x));
float y;
if (x >= 0)
y = 1.f / (1.f + exp(-x));
else {
y = exp(x);
y = y / (1 + y);
}
return y;
}
#ifdef HAVE_HALIDE