From a633bc61b156f3a4a2cd9f313a738ace459befc1 Mon Sep 17 00:00:00 2001 From: Jerry Ge Date: Wed, 9 Nov 2022 14:30:59 -0800 Subject: Fix the floating point precision issue for Sigmoid FP32 The original calculation was auto-promoted to FP64 and causing the discrepencies between TFL and TOSA. Sigmoid is now calculated with only single precision floating point values. Signed-off-by: Jerry Ge Change-Id: Ia65b491ccf8af2493cc01ca66c28faff841407c2 --- reference_model/src/ops/activation_funcs.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reference_model/src/ops/activation_funcs.cc b/reference_model/src/ops/activation_funcs.cc index 46234e2..09ef6f6 100644 --- a/reference_model/src/ops/activation_funcs.cc +++ b/reference_model/src/ops/activation_funcs.cc @@ -63,7 +63,9 @@ int OpSigmoid::register_fcn() case DType_FP16: case DType_BF16: case DType_FP32: - this->fcn = [](InEigenType a) -> OutEigenType { return fpTrunc(1.0 / (1.0 + (expf(-1.0 * a)))); }; + this->fcn = [](InEigenType a) -> OutEigenType { + return fpTrunc(1.f / (1.f + (expf(-1.f * a)))); + }; break; default: ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]); -- cgit v1.2.1