diff options
author | Colm Donelan <colm.donelan@arm.com> | 2023-03-06 12:34:54 +0000 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2023-03-06 22:06:38 +0000 |
commit | d047262b7fb68ad1fe0a2273ee79ab7952c72a6e (patch) | |
tree | 5e35dd8938cea094218fd84abb14d6418711df7d /tests/NetworkExecutionUtils/test | |
parent | 0e5a1317156f97c56baf556ddc8a638228dbec74 (diff) | |
download | armnn-d047262b7fb68ad1fe0a2273ee79ab7952c72a6e.tar.gz |
Fixing compare output feature in ExecuteNetwork
The -A -B -C options in execute network were attempting to calculate
the RMS error over output tensors. However, the calculation was mixing
tensor elements and bytes when doing the calculation. This patch
changes the calculation to use a per byte RMS error calculation.
Signed-off-by: Colm Donelan <colm.donelan@arm.com>
Change-Id: If30230a16cfed1a8804b4d54ed1abcd371f26664
Diffstat (limited to 'tests/NetworkExecutionUtils/test')
-rw-r--r-- | tests/NetworkExecutionUtils/test/NetworkExecutionUtilsTests.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/NetworkExecutionUtils/test/NetworkExecutionUtilsTests.cpp b/tests/NetworkExecutionUtils/test/NetworkExecutionUtilsTests.cpp new file mode 100644 index 0000000000..d11fe571b0 --- /dev/null +++ b/tests/NetworkExecutionUtils/test/NetworkExecutionUtilsTests.cpp @@ -0,0 +1,37 @@ +// +// Copyright © 2023 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "../NetworkExecutionUtils.hpp" + +#include <doctest/doctest.h> + +namespace +{ + +TEST_SUITE("NetworkExecutionUtilsTests") +{ + +TEST_CASE ("ComputeByteLevelRMSE") +{ + // Bytes. + const uint8_t expected[] = {1, 128, 255}; + const uint8_t actual[] = {0, 127, 254}; + + CHECK(ComputeByteLevelRMSE(expected, expected, 3) == 0); + CHECK(ComputeByteLevelRMSE(expected, actual, 3) == 1.0); + + // Floats. + const float expectedFloat[] = + {55.20419, 24.58061, 67.76520, 47.31617, 55.58102, 44.64565, 105.76307, 54.65538, 80.41088, 66.05208}; + const float actualFloat[] = + {13.87187, 14.16160, 49.28846, 25.89192, 97.70659, 91.30055, 15.88831, 4.79960, 102.99205, 51.28290}; + const double expectedResult = 74.059098023; // Calculated manually. + CHECK(ComputeByteLevelRMSE(expectedFloat, expectedFloat, sizeof(float) * 10) == 0); + CHECK(ComputeByteLevelRMSE(expectedFloat, actualFloat, sizeof(float) * 10) == doctest::Approx(expectedResult)); +} + +} // End of TEST_SUITE("NetworkExecutionUtilsTests") + +} // anonymous namespace
\ No newline at end of file |