aboutsummaryrefslogtreecommitdiff
path: root/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp')
-rw-r--r--tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp b/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp
index e3c95d9312..6f9cdf87bc 100644
--- a/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp
+++ b/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp
@@ -78,3 +78,21 @@ void LogAndThrow(std::string eMsg)
throw armnn::Exception(eMsg);
}
+/// Compute the root-mean-square error (RMSE) at a byte level between two tensors of the same size.
+/// @param expected
+/// @param actual
+/// @param size size of the tensor in bytes.
+/// @return float the RMSE
+double ComputeByteLevelRMSE(const void* expected, const void* actual, const size_t size)
+{
+ const uint8_t* byteExpected = reinterpret_cast<const uint8_t*>(expected);
+ const uint8_t* byteActual = reinterpret_cast<const uint8_t*>(actual);
+
+ double errorSum = 0;
+ for (unsigned int i = 0; i < size; i++)
+ {
+ int difference = byteExpected[i] - byteActual[i];
+ errorSum += std::pow(difference, 2);
+ }
+ return std::sqrt(errorSum/armnn::numeric_cast<double>(size));
+}