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/NetworkExecutionUtils.hpp | |
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/NetworkExecutionUtils.hpp')
-rw-r--r-- | tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp b/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp index 8c97238432..2136c446fb 100644 --- a/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp +++ b/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp @@ -73,6 +73,8 @@ std::vector<unsigned int> ParseArray(std::istream& stream); /// Splits a given string at every accurance of delimiter into a vector of string std::vector<std::string> ParseStringList(const std::string& inputString, const char* delimiter); +double ComputeByteLevelRMSE(const void* expected, const void* actual, const size_t size); + /// Dequantize an array of a given type /// @param array Type erased array to dequantize /// @param numElements Elements in the array @@ -285,29 +287,3 @@ std::vector<T> ParseArrayImpl(std::istream& stream, TParseElementFunc parseEleme return result; } - -/// Compute the root-mean-square error (RMSE) -/// @param expected -/// @param actual -/// @param size size of the tensor -/// @return float the RMSE -template<typename T> -float ComputeRMSE(const void* expected, const void* actual, const size_t size) -{ - auto typedExpected = reinterpret_cast<const T*>(expected); - auto typedActual = reinterpret_cast<const T*>(actual); - - T errorSum = 0; - - for (unsigned int i = 0; i < size; i++) - { - if (std::abs(typedExpected[i] - typedActual[i]) != 0) - { - std::cout << ""; - } - errorSum += std::pow(std::abs(typedExpected[i] - typedActual[i]), 2); - } - - float rmse = std::sqrt(armnn::numeric_cast<float>(errorSum) / armnn::numeric_cast<float>(size / sizeof(T))); - return rmse; -}
\ No newline at end of file |