diff options
author | Jeremy Johnson <jeremy.johnson@arm.com> | 2024-02-19 13:57:21 +0000 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2024-02-26 16:20:32 +0000 |
commit | 08965d35f728d93d8b215753b4b270a422fe39c9 (patch) | |
tree | 41a520e5f83d3c5bfa9db559bfc500753ba95bb4 /reference_model/src/verify/verify_utils.h | |
parent | e4c89eb171272c1bc28c188aeb8363009674ba86 (diff) | |
download | reference_model-08965d35f728d93d8b215753b4b270a422fe39c9.tar.gz |
Verifier - change to output largest error deviance
Add general validateData function used by ABS_ERROR, ULP,
RELATIVE and REDUCE_PRODUCT to find and output largest deviance
from the error bounds.
Clean up naming inconsistencies bewteen verify modes.
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
Change-Id: Ib903faf36f784cacae91edab61d8e489461a727c
Diffstat (limited to 'reference_model/src/verify/verify_utils.h')
-rw-r--r-- | reference_model/src/verify/verify_utils.h | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/reference_model/src/verify/verify_utils.h b/reference_model/src/verify/verify_utils.h index 341bd90..0d7bf47 100644 --- a/reference_model/src/verify/verify_utils.h +++ b/reference_model/src/verify/verify_utils.h @@ -22,6 +22,7 @@ #include <cstdint> #include <optional> +#include <string> #include <vector> #define TOSA_REF_REQUIRE(COND, MESSAGE, ...) \ @@ -164,9 +165,43 @@ struct AccPrecision<half_float::half> static constexpr int32_t normal_frac = 7; }; -/// \brief Error bounds check for ULP and ABS_ERROR modes +/// \brief Single value error bounds check for ULP, ABS_ERROR and other compliance modes +/// +/// \param testValue Implementation value +/// \param referenceValue Reference value +/// \param errorBound Positive error bound value +/// \param resultDifference Return: Difference between reference value and implementation value +/// \param resultWarning Return: Warning message if implementation is outside error bounds +/// +/// \return True if compliant else false template <typename OutType> -bool tosaCheckFloatBound(OutType testValue, double referenceValue, double errorBound); +bool tosaCheckFloatBound( + OutType testValue, double referenceValue, double errorBound, double& resultDifference, std::string& resultWarning); + +/// \brief Whole tensor checker for values inside error bounds +/// +/// \param referenceData Reference output tensor data +/// \param boundsData Optional reference bounds tensor data +/// \param implementationData Implementation output tensor data +/// \param shape Tensor shape - all tensors must be this shape +/// \param modeStr Short string indicating which compliance mode we are testing +/// \param cfgPtr Pointer to this mode's configuration data, passed to the calcErrorBound() +/// \param calcErrorBound Pointer to a function that can calculate the error bound per ref value +/// +/// \return True if compliant else false +template <typename OutType> +bool validateData(const double* referenceData, + const double* boundsData, + const OutType* implementationData, + const std::vector<int32_t>& shape, + const std::string& modeStr, + const void* cfgPtr, + double (*calcErrorBound)(double referenceValue, double boundsValue, const void* cfgPtr)); + +// Unused arguments helper function +template <typename... Args> +inline void unused(Args&&...) +{} }; // namespace TosaReference #endif // VERIFY_UTILS_H_ |