blob: acf20c4b692e278faa2590820ba8337792a24a74 [file] [log] [blame]
Derek Lambertif30f7d32019-04-09 10:25:02 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include "BaseIterator.hpp"
9
10namespace armnn
11{
12
13template<typename T>
Nattapat Chaimanowongae2c5f02019-04-24 16:19:57 +010014inline std::unique_ptr<Decoder<T>> MakeDecoder(const TensorInfo& info, const void* data);
Derek Lambertif30f7d32019-04-09 10:25:02 +010015
16template<>
Nattapat Chaimanowongae2c5f02019-04-24 16:19:57 +010017inline std::unique_ptr<Decoder<float>> MakeDecoder(const TensorInfo& info, const void* data)
Derek Lambertif30f7d32019-04-09 10:25:02 +010018{
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 Chaimanowongae2c5f02019-04-24 16:19:57 +010048} //namespace armnn