From 41df428ed5e3b07f0a497fc504f1eddb8e115188 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 30 May 2023 12:20:31 +0100 Subject: 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 Change-Id: I0cced0ff8875ac8d78b1943211438713d1c51b88 --- reference_model/test/verify_tests.cpp | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 reference_model/test/verify_tests.cpp (limited to 'reference_model/test/verify_tests.cpp') 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 + +#include +#include +#include + +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)); + } +} -- cgit v1.2.1