diff options
author | Eric Kunze <eric.kunze@arm.com> | 2024-04-10 15:26:55 -0700 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2024-04-18 08:15:08 -0700 |
commit | 0e121c064e051716bdfca892b210fa52c792ac29 (patch) | |
tree | fe9b31770921ebadd735b7443d9537ca90ce7379 /pseudocode/library/numeric_accuracy_helpers.tosac | |
parent | 9d14082fe5176ec91d006d89ccdb2d62f6ca839f (diff) | |
download | specification-0e121c064e051716bdfca892b210fa52c792ac29.tar.gz |
Clarify error bound for non-normal values
Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Change-Id: I9678952cc78cdf90272ccd5179b6220c293d62f7
Diffstat (limited to 'pseudocode/library/numeric_accuracy_helpers.tosac')
-rw-r--r-- | pseudocode/library/numeric_accuracy_helpers.tosac | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pseudocode/library/numeric_accuracy_helpers.tosac b/pseudocode/library/numeric_accuracy_helpers.tosac index b89d898..dbff2dd 100644 --- a/pseudocode/library/numeric_accuracy_helpers.tosac +++ b/pseudocode/library/numeric_accuracy_helpers.tosac @@ -56,3 +56,17 @@ int normal_frac<in_t> () { case fp8e5m2_t: return 2; } } + +double calcAbsErrorBound<in_t>(double bound_magnitude, double bounds_value, + double lower_bound, double normal_divisor) { + double error_bound = 0.0; + // Avoid cases where we generate an error_bound of NaN by multiplying inf * 0 + if (is_finite(bounds_value) || abs(bound_magnitude) != 0.0) { + double value_bound = abs(bound_magnitude) * bounds_value; + if (lower_bound > 0) { + value_bound = max(lower_bound, value_bound); + } + error_bound = exp2(-normal_frac<in_t> / normal_divisor) * value_bound; + } + return error_bound; +}
\ No newline at end of file |