aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/verify/verify_utils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'reference_model/src/verify/verify_utils.cc')
-rw-r--r--reference_model/src/verify/verify_utils.cc13
1 files changed, 8 insertions, 5 deletions
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;