diff options
author | Sadik Armagan <sadik.armagan@arm.com> | 2021-11-17 15:01:00 +0000 |
---|---|---|
committer | Sadik Armagan <sadik.armagan@arm.com> | 2021-11-18 16:43:17 +0000 |
commit | 1342bed114effa8b183ba683189117cd730ab635 (patch) | |
tree | 8561e8eceb6043d74a0c69197de62fcbd3d8dd8e /src | |
parent | f9de771083f1f32393b0fe5a3bcdedf4c148be15 (diff) | |
download | armnn-1342bed114effa8b183ba683189117cd730ab635.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/armnnUtils/CompatibleTypes.cpp (renamed from src/armnn/CompatibleTypes.hpp) | 30 | ||||
-rw-r--r-- | src/backends/backendsCommon/TensorHandle.hpp | 22 |
2 files changed, 32 insertions, 20 deletions
diff --git a/src/armnn/CompatibleTypes.hpp b/src/armnnUtils/CompatibleTypes.cpp index e24d5dfc4c..9a3251d293 100644 --- a/src/armnn/CompatibleTypes.hpp +++ b/src/armnnUtils/CompatibleTypes.cpp @@ -1,16 +1,16 @@ // -// Copyright © 2017 Arm Ltd. All rights reserved. +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // - -#pragma once - #include <armnn/Types.hpp> +#include <armnnUtils/CompatibleTypes.hpp> + +#include "BFloat16.hpp" +#include "Half.hpp" -#include <BFloat16.hpp> -#include <Half.hpp> +using namespace armnn; -namespace armnn +namespace armnnUtils { template<typename T> @@ -20,46 +20,46 @@ bool CompatibleTypes(DataType) } template<> -inline bool CompatibleTypes<float>(DataType dataType) +bool CompatibleTypes<float>(DataType dataType) { return dataType == DataType::Float32; } template<> -inline bool CompatibleTypes<Half>(DataType dataType) +bool CompatibleTypes<Half>(DataType dataType) { return dataType == DataType::Float16; } template<> -inline bool CompatibleTypes<BFloat16>(DataType dataType) +bool CompatibleTypes<BFloat16>(DataType dataType) { return dataType == DataType::BFloat16; } template<> -inline bool CompatibleTypes<uint8_t>(DataType dataType) +bool CompatibleTypes<uint8_t>(DataType dataType) { return dataType == DataType::Boolean || dataType == DataType::QAsymmU8; } template<> -inline bool CompatibleTypes<int8_t>(DataType dataType) +bool CompatibleTypes<int8_t>(DataType dataType) { return dataType == DataType::QSymmS8 || dataType == DataType::QAsymmS8; } template<> -inline bool CompatibleTypes<int16_t>(DataType dataType) +bool CompatibleTypes<int16_t>(DataType dataType) { return dataType == DataType::QSymmS16; } template<> -inline bool CompatibleTypes<int32_t>(DataType dataType) +bool CompatibleTypes<int32_t>(DataType dataType) { return dataType == DataType::Signed32; } -} //namespace armnn +} //namespace armnnUtils diff --git a/src/backends/backendsCommon/TensorHandle.hpp b/src/backends/backendsCommon/TensorHandle.hpp index b898bd11a5..ba1fc16378 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 @@ public: 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 @@ public: 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: |