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 | |
| 37 | void RefQuantizeWorkload::Execute() const |
| 38 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 39 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 40 | } |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 41 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 42 | void RefQuantizeWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 43 | { |
| 44 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 45 | } |
| 46 | |
| 47 | void RefQuantizeWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
| 48 | { |
| 49 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map()); |
| 50 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map()); |
| 51 | |
| 52 | QuantizeImpl(*inputDecoder, *outputEncoder, m_NumElements); |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | } //namespace armnn |