blob: e93653b37332b33cf8ddfe332e31087f15bb7b7a [file] [log] [blame]
Colm Doneland0472622023-03-06 12:34:54 +00001//
2// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "../NetworkExecutionUtils.hpp"
7
8#include <doctest/doctest.h>
9
10namespace
11{
12
13TEST_SUITE("NetworkExecutionUtilsTests")
14{
15
16TEST_CASE ("ComputeByteLevelRMSE")
17{
18 // Bytes.
19 const uint8_t expected[] = {1, 128, 255};
20 const uint8_t actual[] = {0, 127, 254};
21
22 CHECK(ComputeByteLevelRMSE(expected, expected, 3) == 0);
23 CHECK(ComputeByteLevelRMSE(expected, actual, 3) == 1.0);
24
25 // Floats.
26 const float expectedFloat[] =
Francis Murtagh6d4e7612023-03-23 11:36:34 +000027 {55.20419f, 24.58061f, 67.76520f, 47.31617f, 55.58102f, 44.64565f, 105.76307f, 54.65538f, 80.41088f, 66.05208f};
Colm Doneland0472622023-03-06 12:34:54 +000028 const float actualFloat[] =
Francis Murtagh6d4e7612023-03-23 11:36:34 +000029 {13.87187f, 14.16160f, 49.28846f, 25.89192f, 97.70659f, 91.30055f, 15.88831f, 4.79960f, 102.99205f, 51.28290f};
Colm Doneland0472622023-03-06 12:34:54 +000030 const double expectedResult = 74.059098023; // Calculated manually.
31 CHECK(ComputeByteLevelRMSE(expectedFloat, expectedFloat, sizeof(float) * 10) == 0);
32 CHECK(ComputeByteLevelRMSE(expectedFloat, actualFloat, sizeof(float) * 10) == doctest::Approx(expectedResult));
33}
34
35} // End of TEST_SUITE("NetworkExecutionUtilsTests")
36
37} // anonymous namespace