aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/verify
diff options
context:
space:
mode:
authorJeremy Johnson <jeremy.johnson@arm.com>2023-11-09 16:56:07 +0000
committerJeremy Johnson <jeremy.johnson@arm.com>2023-11-23 14:08:53 +0000
commit0bbd8bcfb20ec834f18d0bb89fc69ba4e92b3019 (patch)
treedca9f00f2ce4a48801fb92e6cee6e531585b3d5d /reference_model/src/verify
parent6ce35028420a208df979ba88807ee8bffe746b63 (diff)
downloadreference_model-0bbd8bcfb20ec834f18d0bb89fc69ba4e92b3019.tar.gz
Main Compliance testing support for LOG and ACTIVATIONs
Increase exp2 allowed range to account for denormals. Minor adjustments to verify to match spec updates for pseudo code. Set ranges of activation function inputs to match spec. Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: I6fcf665932ac2c9080e284b865da8f7746801f59
Diffstat (limited to 'reference_model/src/verify')
-rw-r--r--reference_model/src/verify/verify_abs_error.cc2
-rw-r--r--reference_model/src/verify/verify_ulp.cc9
-rw-r--r--reference_model/src/verify/verify_utils.cc13
3 files changed, 10 insertions, 14 deletions
diff --git a/reference_model/src/verify/verify_abs_error.cc b/reference_model/src/verify/verify_abs_error.cc
index 1afa7fd..b43da08 100644
--- a/reference_model/src/verify/verify_abs_error.cc
+++ b/reference_model/src/verify/verify_abs_error.cc
@@ -32,7 +32,7 @@ bool validateData(const double* ref, const double* bnd, const float* imp, const
for (size_t i = 0; i < T; ++i)
{
- double errBound = ref[i] * exp2(-AccPrecision<float>::normal_frac) * bnd[i];
+ double errBound = std::abs(ref[i]) * exp2(-AccPrecision<float>::normal_frac) * bnd[i];
bool valid = tosaCheckFloatBound(imp[i], ref[i], errBound);
if (!valid)
{
diff --git a/reference_model/src/verify/verify_ulp.cc b/reference_model/src/verify/verify_ulp.cc
index b333810..6e78b96 100644
--- a/reference_model/src/verify/verify_ulp.cc
+++ b/reference_model/src/verify/verify_ulp.cc
@@ -30,15 +30,8 @@ bool tosaCheckULP(float testValue, double referenceValue, double ulpNum)
double errorBound = 0.0;
if (std::isfinite(referenceValue) && std::abs(referenceValue) != 0.0)
{
- // Make the sign of the reference value positive
- // and adjust the test value appropriately.
- if (referenceValue < 0)
- {
- referenceValue = -referenceValue;
- testValue = -testValue;
- }
// Find the exponent of the reference value.
- int32_t referenceExponent = ilog2(referenceValue);
+ int32_t referenceExponent = ilog2(std::abs(referenceValue));
// Work out the values magnitude - by raising 2 to the power of the
// exponent and taking the normalized minimum for denormal values
diff --git a/reference_model/src/verify/verify_utils.cc b/reference_model/src/verify/verify_utils.cc
index 414f7d7..9aa6ba2 100644
--- a/reference_model/src/verify/verify_utils.cc
+++ b/reference_model/src/verify/verify_utils.cc
@@ -170,7 +170,11 @@ DType mapToDType(tosa_datatype_t dataType)
// Like const_exp2 but for use during runtime
double exp2(int32_t n)
{
- TOSA_REF_REQUIRE(-1022 <= n && n <= 1023, " Invalid exponent value (%d) in exp2", n);
+ if (n < -1075)
+ {
+ return 0.0; // smaller than smallest denormal
+ }
+ TOSA_REF_REQUIRE(n <= 1023, " Invalid exponent value (%d) in exp2", n);
return const_exp2(n);
}
@@ -212,6 +216,9 @@ bool tosaCheckFloatBound(float testValue, double referenceValue, double errorBou
return false;
}
+ // Check the errorBound
+ TOSA_REF_REQUIRE(errorBound >= 0.f, " Invalid error bound (%g)", errorBound);
+
// Make the sign of the reference value positive
// and adjust the test value appropriately.
if (referenceValue < 0)
@@ -219,10 +226,6 @@ bool tosaCheckFloatBound(float testValue, double referenceValue, double errorBou
referenceValue = -referenceValue;
testValue = -testValue;
}
- if (errorBound < 0)
- {
- errorBound = -errorBound;
- }
// At this point we are ready to calculate the ULP bounds for the reference value.
double referenceMin, referenceMax;