diff options
-rw-r--r-- | reference_model/src/ops/activation_funcs.cc | 20 | ||||
-rw-r--r-- | verif/generator/tosa_test_gen.py | 4 |
2 files changed, 19 insertions, 5 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)); diff --git a/verif/generator/tosa_test_gen.py b/verif/generator/tosa_test_gen.py index 0a8d035..ba10dcf 100644 --- a/verif/generator/tosa_test_gen.py +++ b/verif/generator/tosa_test_gen.py @@ -341,7 +341,7 @@ class TosaTestGen: compliance_tens["ulp_info"] = {"ulp": op["compliance"]["ulp"]} elif op["op"] == Op.REDUCE_PRODUCT: mode = gtu.ComplianceMode.REDUCE_PRODUCT - elif op["op"] in (Op.EXP, Op.POW): + elif op["op"] in (Op.EXP, Op.POW, Op.TANH, Op.SIGMOID): mode = gtu.ComplianceMode.ABS_ERROR else: mode = gtu.ComplianceMode.EXACT @@ -3243,7 +3243,6 @@ class TosaTestGen: "data_gen": { "fp": (gtu.DataGenType.PSEUDO_RANDOM,), }, - "compliance": {"ulp": 5}, }, "tanh": { "op": Op.TANH, @@ -3264,7 +3263,6 @@ class TosaTestGen: "data_gen": { "fp": (gtu.DataGenType.PSEUDO_RANDOM,), }, - "compliance": {"ulp": 5}, }, "erf": { "op": Op.ERF, |