• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "RefGatherWorkload.hpp"
7 
8 #include "Gather.hpp"
9 #include "Profiling.hpp"
10 #include "RefWorkloadUtils.hpp"
11 #include <ResolveType.hpp>
12 
13 namespace armnn
14 {
15 
Execute() const16 void RefGatherWorkload::Execute() const
17 {
18     Execute(m_Data.m_Inputs, m_Data.m_Outputs);
19 }
20 
ExecuteAsync(ExecutionData & executionData)21 void RefGatherWorkload::ExecuteAsync(ExecutionData& executionData)
22 {
23     WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
24     Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
25 }
26 
Execute(std::vector<ITensorHandle * > inputs,std::vector<ITensorHandle * > outputs) const27 void RefGatherWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
28 {
29     ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefGatherWorkload_Execute");
30 
31     const TensorInfo& inputInfo0 = GetTensorInfo(inputs[0]);
32     const TensorInfo& inputInfo1 = GetTensorInfo(inputs[1]);
33     const TensorInfo& outputInfo = GetTensorInfo(outputs[0]);
34 
35     std::unique_ptr<Decoder<float>> decoderPtr = MakeDecoder<float>(inputInfo0, inputs[0]->Map());
36     Decoder<float>& decoder = *decoderPtr;
37 
38     const int32_t* indicesData = reinterpret_cast<int32_t*>(inputs[1]->Map());
39 
40     std::unique_ptr<Encoder<float>> encoderPtr = MakeEncoder<float>(outputInfo, outputs[0]->Map());
41     Encoder<float>& encoder = *encoderPtr;
42 
43     Gather(inputInfo0, inputInfo1, outputInfo, decoder, indicesData, encoder, m_Data.m_Parameters.m_Axis);
44 }
45 
46 } //namespace armnn
47