narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefGatherWorkload.hpp" |
| 7 | |
| 8 | #include "Gather.hpp" |
| 9 | #include "Profiling.hpp" |
| 10 | #include "RefWorkloadUtils.hpp" |
Aron Virginas-Tar | d4f0fea | 2019-04-09 14:08:06 +0100 | [diff] [blame] | 11 | #include <ResolveType.hpp> |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
Ellen Norris-Thompson | 6858d3f | 2019-06-21 15:50:00 +0100 | [diff] [blame] | 16 | void RefGatherWorkload::Execute() const |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 17 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 18 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 19 | } |
| 20 | |
| 21 | void RefGatherWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 22 | { |
| 23 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 24 | } |
| 25 | |
| 26 | void RefGatherWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
| 27 | { |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 28 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefGatherWorkload_Execute"); |
| 29 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 30 | const TensorInfo& inputInfo0 = GetTensorInfo(inputs[0]); |
| 31 | const TensorInfo& inputInfo1 = GetTensorInfo(inputs[1]); |
| 32 | const TensorInfo& outputInfo = GetTensorInfo(outputs[0]); |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 33 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 34 | std::unique_ptr<Decoder<float>> decoderPtr = MakeDecoder<float>(inputInfo0, inputs[0]->Map()); |
Ellen Norris-Thompson | 6858d3f | 2019-06-21 15:50:00 +0100 | [diff] [blame] | 35 | Decoder<float>& decoder = *decoderPtr; |
| 36 | |
Finn Williams | 0109794 | 2021-04-26 12:06:34 +0100 | [diff] [blame] | 37 | const int32_t* indicesData = reinterpret_cast<int32_t*>(inputs[1]->Map()); |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 38 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 39 | std::unique_ptr<Encoder<float>> encoderPtr = MakeEncoder<float>(outputInfo, outputs[0]->Map()); |
Ellen Norris-Thompson | 6858d3f | 2019-06-21 15:50:00 +0100 | [diff] [blame] | 40 | Encoder<float>& encoder = *encoderPtr; |
| 41 | |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 42 | Gather(inputInfo0, inputInfo1, outputInfo, decoder, indicesData, encoder, m_Data.m_Parameters.m_Axis); |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 43 | } |
| 44 | |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 45 | } //namespace armnn |