Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefQuantizeWorkload.hpp" |
| 7 | |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 8 | #include "RefWorkloadUtils.hpp" |
| 9 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 10 | #include <armnn/TypesUtils.hpp> |
| 11 | |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | namespace |
| 17 | { |
| 18 | |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 19 | void QuantizeImpl(Decoder<float>& in, Encoder<float>& out, size_t numValues) |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 20 | { |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 21 | for (unsigned int i = 0; i < numValues; i++) |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 22 | { |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 23 | in[i]; |
| 24 | out[i]; |
| 25 | out.Set(in.Get()); |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 26 | } |
| 27 | } |
| 28 | |
| 29 | } //namespace |
| 30 | |
| 31 | RefQuantizeWorkload::RefQuantizeWorkload(const QuantizeQueueDescriptor& descriptor, const WorkloadInfo &info) |
| 32 | : BaseWorkload(descriptor, info) |
| 33 | , m_NumElements(info.m_InputTensorInfos[0].GetNumElements()) |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 34 | { |
| 35 | } |
| 36 | |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 37 | void RefQuantizeWorkload::PostAllocationConfigure() |
| 38 | { |
| 39 | const TensorInfo& inputInfo = armnn::GetTensorInfo(m_Data.m_Inputs[0]); |
| 40 | m_InputDecoder = MakeDecoder<float>(inputInfo); |
| 41 | |
| 42 | const TensorInfo& outputInfo = armnn::GetTensorInfo(m_Data.m_Outputs[0]); |
| 43 | m_OutputEncoder = MakeEncoder<float>(outputInfo); |
| 44 | } |
| 45 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 46 | void RefQuantizeWorkload::Execute() const |
| 47 | { |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 48 | m_InputDecoder->Reset(m_Data.m_Inputs[0]->Map()); |
| 49 | m_OutputEncoder->Reset(m_Data.m_Outputs[0]->Map()); |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 50 | |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 51 | QuantizeImpl(*m_InputDecoder, *m_OutputEncoder, m_NumElements); |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | } //namespace armnn |