diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2023-05-30 12:20:31 +0100 |
---|---|---|
committer | Dominic Symes <dominic.symes@arm.com> | 2023-06-15 13:49:08 +0000 |
commit | 41df428ed5e3b07f0a497fc504f1eddb8e115188 (patch) | |
tree | 48dcbabf230d30c3bd1fdb2602164dadcaf3cb05 /reference_model/test | |
parent | 6168047ef0354927cb175ad295722924dfc3053c (diff) | |
download | reference_model-41df428ed5e3b07f0a497fc504f1eddb8e115188.tar.gz |
Add TOSA MI verification methods
Adds utility functions that enable compliance verification of TOSA MI
operators; as per section 1.8.2 in the TOSA specification.
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Change-Id: I0cced0ff8875ac8d78b1943211438713d1c51b88
Diffstat (limited to 'reference_model/test')
-rw-r--r-- | reference_model/test/verify_tests.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/reference_model/test/verify_tests.cpp b/reference_model/test/verify_tests.cpp new file mode 100644 index 0000000..f43804f --- /dev/null +++ b/reference_model/test/verify_tests.cpp @@ -0,0 +1,56 @@ +// Copyright (c) 2023, ARM Limited. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "verify.h" + +#include <doctest.h> + +#include <array> +#include <numeric> +#include <vector> + +TEST_SUITE("verify") +{ + TEST_CASE("check_element_accfp32") + { + const size_t KS = 27; + + // Negative (bnd == 0.0) + REQUIRE_FALSE(tosa_validate_element_accfp32(0.0, 0.0, 1.0, KS).is_valid); + REQUIRE_FALSE(tosa_validate_element_accfp32(1.0, 0.0, 0.0, KS).is_valid); + // Negative (bnd > 0.0) + REQUIRE_FALSE(tosa_validate_element_accfp32(5.0, 5.0, 5.1, KS).is_valid); + + // Positive (bnd == 0.0 && ref == 0.0 && imp == 0.0) + REQUIRE(tosa_validate_element_accfp32(0.0, 0.0, 0.0, KS).is_valid); + REQUIRE(tosa_validate_element_accfp32(0.0, 0.0, 0.0, KS).error == 0.0); + + // Positive (bnd > 0.0) + REQUIRE(tosa_validate_element_accfp32(4.0, 4.0, 4.0, KS).error == 0.0); + REQUIRE(tosa_validate_element_accfp32(4.0, 4.0, 4.0, KS).error == 0.0); + REQUIRE(tosa_validate_element_accfp32(4.0, 4.0, 4.0, KS).error == 0.0); + } + TEST_CASE("check_output_error") + { + const size_t KS = 27; + const size_t T = 1024; + + // Negative (S!=1 && S!=2 && (abs(err_sum) > 2*sqrt(KS*T))) + REQUIRE_FALSE(tosa_validate_output_error(1560, 112000, KS, T, 0)); + // Negative (err_sum_sq > 0.4*KS*T)) + REQUIRE_FALSE(tosa_validate_output_error(1560, 112000, KS, T, 1)); + // Positive + REQUIRE(tosa_validate_output_error(10, 254, KS, T, 0)); + REQUIRE(tosa_validate_output_error(10, 254, KS, T, 1)); + } +} |