blob: 7c8d1ab787b75091dcd78bec6d14ef296944fae1 [file] [log] [blame]
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +01001//
Teresa Charlin52664732020-06-29 16:27:03 +01002// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "ClGatherWorkload.hpp"
7#include "ClWorkloadUtils.hpp"
8#include <aclCommon/ArmComputeUtils.hpp>
9#include <cl/ClTensorHandle.hpp>
10
11using namespace armnn::armcomputetensorutils;
12
13namespace armnn
14{
15arm_compute::Status ClGatherWorkloadValidate(const TensorInfo& input,
16 const TensorInfo& indices,
Teresa Charlin52664732020-06-29 16:27:03 +010017 const TensorInfo& output,
18 const GatherDescriptor& descriptor)
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010019{
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
Teresa Charlin52664732020-06-29 16:27:03 +010024 int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010025
26 return arm_compute::CLGather::validate(&aclInput, &aclIndices, &aclOutput, aclAxis);
27}
28
29ClGatherWorkload::ClGatherWorkload(const GatherQueueDescriptor& descriptor,
Sadik Armagane9444752020-12-02 11:28:58 +000030 const WorkloadInfo& info,
31 const arm_compute::CLCompileContext& clCompileContext)
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010032 : BaseWorkload<GatherQueueDescriptor>(descriptor, info)
33{
Keith Davisbcd860a2021-08-05 14:20:33 +010034 // Report Profiling Details
35 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClGatherWorkload_Construct",
36 descriptor.m_Parameters,
37 info,
38 this->GetGuid());
39
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010040 m_Data.ValidateInputsOutputs("ClGatherWorkload", 1, 1);
41
42 arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
43 arm_compute::ICLTensor& indices = static_cast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
44 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
45
Teresa Charlin52664732020-06-29 16:27:03 +010046 int aclAxis = ComputeAclAxis(descriptor.m_Parameters.m_Axis, info.m_InputTensorInfos[0]);
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010047
Sadik Armagane9444752020-12-02 11:28:58 +000048 m_Layer.configure(clCompileContext, &input, &indices, &output, aclAxis);
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010049};
50
51void ClGatherWorkload::Execute() const
52{
Keith Davisbcd860a2021-08-05 14:20:33 +010053 ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClGatherWorkload_Execute", this->GetGuid());
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010054 RunClFunction(m_Layer, CHECK_LOCATION());
55}
56} // namespace armnn