aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/verify/verify_utils.cc
diff options
context:
space:
mode:
authorJeremy Johnson <jeremy.johnson@arm.com>2023-11-30 14:18:19 +0000
committerJeremy Johnson <jeremy.johnson@arm.com>2023-12-04 10:02:15 +0000
commit718f347a2d886381de19420b5b5b99db8f2b7338 (patch)
tree87f6ab932029654b4e0704938dbe6ab7135da27d /reference_model/src/verify/verify_utils.cc
parentfe79accba2c220036c7b5ea0aa27bff5ef74ec73 (diff)
downloadreference_model-718f347a2d886381de19420b5b5b99db8f2b7338.tar.gz
Main Compliance FP16 support - generate and verify.
FP16 support for all existing operators for compliance: * DOT_PRODUCT * ULP * EXACT * ABS_ERROR Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: I8d25448a793375b53880da3787d8f839767f02cf
Diffstat (limited to 'reference_model/src/verify/verify_utils.cc')
-rw-r--r--reference_model/src/verify/verify_utils.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/reference_model/src/verify/verify_utils.cc b/reference_model/src/verify/verify_utils.cc
index 9aa6ba2..3bdc99f 100644
--- a/reference_model/src/verify/verify_utils.cc
+++ b/reference_model/src/verify/verify_utils.cc
@@ -202,7 +202,8 @@ static_assert(std::numeric_limits<double>::is_iec559,
"TOSA Reference Model has not been built with standard IEEE 754 64-bit float support; Bounds based "
"verification is invalid");
-bool tosaCheckFloatBound(float testValue, double referenceValue, double errorBound)
+template <typename OutType>
+bool tosaCheckFloatBound(OutType testValue, double referenceValue, double errorBound)
{
// Both must be NaNs to be correct
if (std::isnan(referenceValue) || std::isnan(testValue))
@@ -236,8 +237,8 @@ bool tosaCheckFloatBound(float testValue, double referenceValue, double errorBou
{
// We already canonicalized the input such that the reference value is positive
// so no need to check again here.
- referenceMin = std::numeric_limits<float>::infinity();
- referenceMax = std::numeric_limits<float>::infinity();
+ referenceMin = std::numeric_limits<OutType>::infinity();
+ referenceMax = std::numeric_limits<OutType>::infinity();
}
else if (referenceValue == 0)
{
@@ -253,23 +254,23 @@ bool tosaCheckFloatBound(float testValue, double referenceValue, double errorBou
referenceMin = referenceValue - errorBound;
// Handle the overflow cases.
- if (referenceMax > AccPrecision<float>::normal_max)
+ if (referenceMax > AccPrecision<OutType>::normal_max)
{
- referenceMax = std::numeric_limits<float>::infinity();
+ referenceMax = std::numeric_limits<OutType>::infinity();
}
- if (referenceMin > AccPrecision<float>::normal_max)
+ if (referenceMin > AccPrecision<OutType>::normal_max)
{
- referenceMin = std::numeric_limits<float>::infinity();
+ referenceMin = std::numeric_limits<OutType>::infinity();
}
// And the underflow cases.
- if (referenceMax < AccPrecision<float>::normal_min)
+ if (referenceMax < AccPrecision<OutType>::normal_min)
{
- referenceMax = AccPrecision<float>::normal_min;
+ referenceMax = AccPrecision<OutType>::normal_min;
}
- if (referenceMin < AccPrecision<float>::normal_min)
+ if (referenceMin < AccPrecision<OutType>::normal_min)
{
referenceMin = 0.0;
}
@@ -286,4 +287,8 @@ bool tosaCheckFloatBound(float testValue, double referenceValue, double errorBou
}
return withinBound;
}
+
+// Instantiate the needed check functions
+template bool tosaCheckFloatBound(float testValue, double referenceValue, double errorBound);
+template bool tosaCheckFloatBound(half_float::half testValue, double referenceValue, double errorBound);
} // namespace TosaReference