From 3674f1459664f69eaaaae45fe463237835a93d71 Mon Sep 17 00:00:00 2001 From: Keith Davis Date: Sun, 16 Aug 2020 23:44:15 +0100 Subject: IVGCVSW-5107 Allow Split to use subtensor on x and y Signed-off-by: Keith Davis Change-Id: I2370d260b750f36842c23f08e8a00ccf976d0aed --- src/backends/backendsCommon/test/CommonTestUtils.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/backends/backendsCommon') diff --git a/src/backends/backendsCommon/test/CommonTestUtils.hpp b/src/backends/backendsCommon/test/CommonTestUtils.hpp index e96edc8317..8c4da621ed 100644 --- a/src/backends/backendsCommon/test/CommonTestUtils.hpp +++ b/src/backends/backendsCommon/test/CommonTestUtils.hpp @@ -8,9 +8,11 @@ #include #include #include +#include #include +#include #include #include @@ -50,6 +52,23 @@ bool Contains(const MapType& map, const typename MapType::key_type& key) return map.find(key) != map.end(); } +// Utility template for comparing tensor elements +template> +bool Compare(T a, T b, float tolerance = 0.000001f) +{ + if (ArmnnType == armnn::DataType::Boolean) + { + // NOTE: Boolean is represented as uint8_t (with zero equals + // false and everything else equals true), therefore values + // need to be casted to bool before comparing them + return static_cast(a) == static_cast(b); + } + + // NOTE: All other types can be cast to float and compared with + // a certain level of tolerance + return std::fabs(static_cast(a) - static_cast(b)) <= tolerance; +} + template void SetWeightAndBias(ConvolutionLayer* layer, const armnn::TensorInfo& weightInfo, const armnn::TensorInfo& biasInfo) { -- cgit v1.2.1