Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "BaseIterator.hpp" |
| 9 | |
| 10 | namespace armnn |
| 11 | { |
| 12 | |
| 13 | template<typename T> |
Nattapat Chaimanowong | ae2c5f0 | 2019-04-24 16:19:57 +0100 | [diff] [blame] | 14 | inline std::unique_ptr<Decoder<T>> MakeDecoder(const TensorInfo& info, const void* data); |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 15 | |
| 16 | template<> |
Nattapat Chaimanowong | ae2c5f0 | 2019-04-24 16:19:57 +0100 | [diff] [blame] | 17 | inline std::unique_ptr<Decoder<float>> MakeDecoder(const TensorInfo& info, const void* data) |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 18 | { |
| 19 | switch(info.GetDataType()) |
| 20 | { |
| 21 | case armnn::DataType::QuantisedAsymm8: |
| 22 | { |
| 23 | return std::make_unique<QASymm8Decoder>( |
| 24 | static_cast<const uint8_t*>(data), |
| 25 | info.GetQuantizationScale(), |
| 26 | info.GetQuantizationOffset()); |
| 27 | } |
| 28 | case armnn::DataType::QuantisedSymm16: |
| 29 | { |
| 30 | return std::make_unique<QSymm16Decoder>( |
| 31 | static_cast<const int16_t*>(data), |
| 32 | info.GetQuantizationScale(), |
| 33 | info.GetQuantizationOffset()); |
| 34 | } |
| 35 | case armnn::DataType::Float32: |
| 36 | { |
| 37 | return std::make_unique<FloatDecoder>(static_cast<const float*>(data)); |
| 38 | } |
| 39 | default: |
| 40 | { |
| 41 | BOOST_ASSERT_MSG(false, "Not supported Data Type!"); |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | return nullptr; |
| 46 | } |
| 47 | |
Nattapat Chaimanowong | ae2c5f0 | 2019-04-24 16:19:57 +0100 | [diff] [blame] | 48 | } //namespace armnn |