aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/test/TensorHelpers.hpp
diff options
context:
space:
mode:
authorkevmay01 <kevin.may@arm.com>2019-01-24 14:05:09 +0000
committerkevmay01 <kevin.may@arm.com>2019-01-24 14:05:09 +0000
commit2b4d88e34ac1f965417fd236fd4786f26bae2042 (patch)
tree4518b52c6a22e33c4b467588a2843c9d5f1a9ee6 /src/armnn/test/TensorHelpers.hpp
parent94412aff782472be54dce4328e2ecee0225b3e97 (diff)
downloadarmnn-2b4d88e34ac1f965417fd236fd4786f26bae2042.tar.gz
IVGCVSW-2503 Refactor RefElementwiseWorkload around Equal and Greater
* Remove Equal and Greater from RefElementwiseWorkload * Create RefComparisonWorkload and add Equal and Greater * Update ElementwiseFunction for different input/output types * Update TfParser to create Equal/Greater with Boolean output * Update relevant tests to check for Boolean comparison Change-Id: I299b7f2121769c960ac0c6139764a5f3c89c9c32
Diffstat (limited to 'src/armnn/test/TensorHelpers.hpp')
-rw-r--r--src/armnn/test/TensorHelpers.hpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/armnn/test/TensorHelpers.hpp b/src/armnn/test/TensorHelpers.hpp
index 06818d3918..fcaa0772a0 100644
--- a/src/armnn/test/TensorHelpers.hpp
+++ b/src/armnn/test/TensorHelpers.hpp
@@ -67,11 +67,16 @@ bool SelectiveCompare(T a, T b)
return SelectiveComparer<T, armnn::IsQuantizedType<T>()>::Compare(a, b);
};
-
+template<typename T>
+bool SelectiveCompareBoolean(T a, T b)
+{
+ return (((a == 0) && (b == 0)) || ((a != 0) && (b != 0)));
+};
template <typename T, std::size_t n>
boost::test_tools::predicate_result CompareTensors(const boost::multi_array<T, n>& a,
- const boost::multi_array<T, n>& b)
+ const boost::multi_array<T, n>& b,
+ bool compareBoolean = false)
{
// Checks they are same shape.
for (unsigned int i=0; i<n; i++)
@@ -103,7 +108,17 @@ boost::test_tools::predicate_result CompareTensors(const boost::multi_array<T, n
while (true)
{
- bool comparison = SelectiveCompare(a(indices), b(indices));
+ bool comparison;
+ // As true for uint8_t is non-zero (1-255) we must have a dedicated compare for Booleans.
+ if(compareBoolean)
+ {
+ comparison = SelectiveCompareBoolean(a(indices), b(indices));
+ }
+ else
+ {
+ comparison = SelectiveCompare(a(indices), b(indices));
+ }
+
if (!comparison)
{
++numFailedElements;