ArmNN
 20.11
ClGatherWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClGatherWorkload.hpp"
7 #include "ClWorkloadUtils.hpp"
9 #include <cl/ClTensorHandle.hpp>
10 
11 using namespace armnn::armcomputetensorutils;
12 
13 namespace armnn
14 {
16  const TensorInfo& indices,
17  const TensorInfo& output,
18  const GatherDescriptor& descriptor)
19 {
20  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclIndices = BuildArmComputeTensorInfo(indices);
22  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
23 
24  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
25 
26  return arm_compute::CLGather::validate(&aclInput, &aclIndices, &aclOutput, aclAxis);
27 }
28 
30  const WorkloadInfo& info)
31  : BaseWorkload<GatherQueueDescriptor>(descriptor, info)
32 {
33  m_Data.ValidateInputsOutputs("ClGatherWorkload", 1, 1);
34 
35  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
36  arm_compute::ICLTensor& indices = static_cast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
37  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
38 
39  int aclAxis = ComputeAclAxis(descriptor.m_Parameters.m_Axis, info.m_InputTensorInfos[0]);
40 
41  m_Layer.configure(&input, &indices, &output, aclAxis);
42 };
43 
45 {
46  ARMNN_SCOPED_PROFILING_EVENT_CL("ClGatherWorkload_Execute");
47  RunClFunction(m_Layer, CHECK_LOCATION());
48 }
49 } // namespace armnn
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank...
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
const GatherQueueDescriptor m_Data
Definition: Workload.hpp:46
ClGatherWorkload(const GatherQueueDescriptor &descriptor, const WorkloadInfo &info)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2020 ARM Limited.
std::vector< TensorInfo > m_InputTensorInfos
A GatherDescriptor for the GatherLayer.
Status
enumeration
Definition: Types.hpp:26
arm_compute::Status ClGatherWorkloadValidate(const TensorInfo &input, const TensorInfo &indices, const TensorInfo &output, const GatherDescriptor &descriptor)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
int32_t m_Axis
The axis in params to gather indices from.
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs
void Execute() const override