diff options
author | Jeremy Johnson <jeremy.johnson@arm.com> | 2023-12-04 11:11:06 +0000 |
---|---|---|
committer | Jeremy Johnson <jeremy.johnson@arm.com> | 2023-12-04 11:11:06 +0000 |
commit | 534923df858de76c6e0b0a2689cc23917e873548 (patch) | |
tree | 86df0f484ceb58a7b210c9603d8e3188253f7ce8 /reference_model/src/ops/activation_funcs.cc | |
parent | 718f347a2d886381de19420b5b5b99db8f2b7338 (diff) | |
download | reference_model-534923df858de76c6e0b0a2689cc23917e873548.tar.gz |
Change TANH, SIGMOID to ABS_ERROR compliance
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
Change-Id: Icf04afc7fdae8f506ba4710aaa085d6ea53bb5bf
Diffstat (limited to 'reference_model/src/ops/activation_funcs.cc')
-rw-r--r-- | reference_model/src/ops/activation_funcs.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/reference_model/src/ops/activation_funcs.cc b/reference_model/src/ops/activation_funcs.cc index 8ca77f7..ce58d77 100644 --- a/reference_model/src/ops/activation_funcs.cc +++ b/reference_model/src/ops/activation_funcs.cc @@ -89,7 +89,15 @@ int OpSigmoid<Rank, Dtype>::register_fcn() this->fcn = [](InEigenType a) -> OutEigenType { return fpTrunc<Dtype>(1.f / (1.f + (expf(-1.f * a)))); }; break; case TOSA_REF_TYPE_FP64: - this->fcn = [](InEigenType a) -> OutEigenType { return (1.L / (1.L + (exp(-1.L * a)))); }; + if (g_func_config.abs_mode) + { + // ABS_ERROR bounds return 2*(1+abs(a)) + this->fcn = [](InEigenType a) -> OutEigenType { return 2.0 * (1.0 + (a > (InEigenType)0 ? a : (-a))); }; + } + else + { + this->fcn = [](InEigenType a) -> OutEigenType { return (1.L / (1.L + (exp(-1.L * a)))); }; + } break; default: ERROR_IF(true, "unsupported TOSA_REF_TYPE %s", EnumNameTOSAREFTYPE(Dtype)); @@ -113,7 +121,15 @@ int OpTanh<Rank, Dtype>::register_fcn() this->fcn = [](InEigenType a) -> OutEigenType { return fpTrunc<Dtype>(tanhf(a)); }; break; case TOSA_REF_TYPE_FP64: - this->fcn = [](InEigenType a) -> OutEigenType { return tanh(a); }; + if (g_func_config.abs_mode) + { + // ABS_ERROR bounds return 2*(1+abs(a)) + this->fcn = [](InEigenType a) -> OutEigenType { return 2.0 * (1.0 + (a > (InEigenType)0 ? a : (-a))); }; + } + else + { + this->fcn = [](InEigenType a) -> OutEigenType { return tanh(a); }; + } break; default: ERROR_IF(true, "unsupported TOSA_REF_TYPE %s", EnumNameTOSAREFTYPE(Dtype)); |