IVGCVSW-6452 'Move CompatibleTypes.hpp to the armnnUtils library'

* Moved CompatibleTypes.hpp to include folder
* Added implementation file to source CompatibleTypes.cpp

Signed-off-by: Sadik Armagan <sadik.armagan@arm.com>
Change-Id: I94d2bffdb82a0592943f497d4f57972151d9f2db
diff --git a/Android.mk b/Android.mk
index e39a0e8..c3cb155 100644
--- a/Android.mk
+++ b/Android.mk
@@ -144,6 +144,7 @@
         src/armnn/Utils.cpp \
         src/armnn/WallClockTimer.cpp \
         src/armnn/WorkingMemHandle.cpp \
+        src/armnnUtils/CompatibleTypes.cpp \
         src/armnnUtils/DataLayoutIndexed.cpp \
         src/armnnUtils/DotSerializer.cpp \
         src/armnnUtils/FloatingPointConverter.cpp \
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ea40de..fde0582 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,6 +71,7 @@
 
 set(armnnUtils_sources)
 list(APPEND armnnUtils_sources
+    include/armnnUtils/CompatibleTypes.hpp
     include/armnnUtils/DataLayoutIndexed.hpp
     include/armnnUtils/Permute.hpp
     include/armnnUtils/Filesystem.hpp
@@ -81,6 +82,7 @@
     include/armnnUtils/Threads.hpp
     include/armnnUtils/Transpose.hpp
     src/armnnUtils/BFloat16.hpp
+    src/armnnUtils/CompatibleTypes.cpp
     src/armnnUtils/Filesystem.cpp
     src/armnnUtils/GraphTopologicalSort.hpp
     src/armnnUtils/Half.hpp
@@ -362,7 +364,6 @@
     src/armnn/BackendRegistry.cpp
     src/armnn/BackendSettings.hpp
     src/armnn/BackendHelper.cpp
-    src/armnn/CompatibleTypes.hpp
     src/armnn/Descriptors.cpp
     src/armnn/DeviceSpec.hpp
     src/armnn/DllExport.hpp
diff --git a/include/armnnUtils/CompatibleTypes.hpp b/include/armnnUtils/CompatibleTypes.hpp
new file mode 100644
index 0000000..0640fcc
--- /dev/null
+++ b/include/armnnUtils/CompatibleTypes.hpp
@@ -0,0 +1,16 @@
+//
+// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <armnn/Types.hpp>
+
+namespace armnnUtils
+{
+
+template<typename T>
+bool CompatibleTypes(armnn::DataType);
+
+} //namespace armnnUtils
diff --git a/src/armnn/CompatibleTypes.hpp b/src/armnn/CompatibleTypes.hpp
deleted file mode 100644
index e24d5df..0000000
--- a/src/armnn/CompatibleTypes.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <armnn/Types.hpp>
-
-#include <BFloat16.hpp>
-#include <Half.hpp>
-
-namespace armnn
-{
-
-template<typename T>
-bool CompatibleTypes(DataType)
-{
-    return false;
-}
-
-template<>
-inline bool CompatibleTypes<float>(DataType dataType)
-{
-    return dataType == DataType::Float32;
-}
-
-template<>
-inline bool CompatibleTypes<Half>(DataType dataType)
-{
-    return dataType == DataType::Float16;
-}
-
-template<>
-inline bool CompatibleTypes<BFloat16>(DataType dataType)
-{
-    return dataType == DataType::BFloat16;
-}
-
-template<>
-inline bool CompatibleTypes<uint8_t>(DataType dataType)
-{
-    return dataType == DataType::Boolean || dataType == DataType::QAsymmU8;
-}
-
-template<>
-inline bool CompatibleTypes<int8_t>(DataType dataType)
-{
-    return dataType == DataType::QSymmS8
-        || dataType == DataType::QAsymmS8;
-}
-
-template<>
-inline bool CompatibleTypes<int16_t>(DataType dataType)
-{
-    return dataType == DataType::QSymmS16;
-}
-
-template<>
-inline bool CompatibleTypes<int32_t>(DataType dataType)
-{
-    return dataType == DataType::Signed32;
-}
-
-} //namespace armnn
diff --git a/src/armnnUtils/CompatibleTypes.cpp b/src/armnnUtils/CompatibleTypes.cpp
new file mode 100644
index 0000000..9a3251d
--- /dev/null
+++ b/src/armnnUtils/CompatibleTypes.cpp
@@ -0,0 +1,65 @@
+//
+// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#include <armnn/Types.hpp>
+#include <armnnUtils/CompatibleTypes.hpp>
+
+#include "BFloat16.hpp"
+#include "Half.hpp"
+
+using namespace armnn;
+
+namespace armnnUtils
+{
+
+template<typename T>
+bool CompatibleTypes(DataType)
+{
+    return false;
+}
+
+template<>
+bool CompatibleTypes<float>(DataType dataType)
+{
+    return dataType == DataType::Float32;
+}
+
+template<>
+bool CompatibleTypes<Half>(DataType dataType)
+{
+    return dataType == DataType::Float16;
+}
+
+template<>
+bool CompatibleTypes<BFloat16>(DataType dataType)
+{
+    return dataType == DataType::BFloat16;
+}
+
+template<>
+bool CompatibleTypes<uint8_t>(DataType dataType)
+{
+    return dataType == DataType::Boolean || dataType == DataType::QAsymmU8;
+}
+
+template<>
+bool CompatibleTypes<int8_t>(DataType dataType)
+{
+    return dataType == DataType::QSymmS8
+        || dataType == DataType::QAsymmS8;
+}
+
+template<>
+bool CompatibleTypes<int16_t>(DataType dataType)
+{
+    return dataType == DataType::QSymmS16;
+}
+
+template<>
+bool CompatibleTypes<int32_t>(DataType dataType)
+{
+    return dataType == DataType::Signed32;
+}
+
+} //namespace armnnUtils
diff --git a/src/backends/backendsCommon/TensorHandle.hpp b/src/backends/backendsCommon/TensorHandle.hpp
index b898bd1..ba1fc16 100644
--- a/src/backends/backendsCommon/TensorHandle.hpp
+++ b/src/backends/backendsCommon/TensorHandle.hpp
@@ -10,7 +10,7 @@
 
 #include <armnn/TypesUtils.hpp>
 
-#include <CompatibleTypes.hpp>
+#include <armnnUtils/CompatibleTypes.hpp>
 
 #include <algorithm>
 
@@ -30,8 +30,14 @@
     template <typename T>
     const T* GetConstTensor() const
     {
-        ARMNN_ASSERT(CompatibleTypes<T>(GetTensorInfo().GetDataType()));
-        return reinterpret_cast<const T*>(m_Memory);
+        if (armnnUtils::CompatibleTypes<T>(GetTensorInfo().GetDataType()))
+        {
+            return reinterpret_cast<const T*>(m_Memory);
+        }
+        else
+        {
+            throw armnn::Exception("Attempting to get not compatible type tensor!");
+        }
     }
 
     const TensorInfo& GetTensorInfo() const
@@ -79,8 +85,14 @@
     template <typename T>
     T* GetTensor() const
     {
-        ARMNN_ASSERT(CompatibleTypes<T>(GetTensorInfo().GetDataType()));
-        return reinterpret_cast<T*>(m_MutableMemory);
+        if (armnnUtils::CompatibleTypes<T>(GetTensorInfo().GetDataType()))
+        {
+            return reinterpret_cast<T*>(m_MutableMemory);
+        }
+        else
+        {
+            throw armnn::Exception("Attempting to get not compatible type tensor!");
+        }
     }
 
 protected: