blob: 55bf422d1944c426db16f66302885830326a16c8 [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 Charlin588cbdf2022-01-19 15:55:37 +000032 : ClBaseWorkload<GatherQueueDescriptor>(descriptor, info)
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010033{
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 Charlin2ea38c72021-11-02 16:43:57 +000040 m_Data.ValidateInputsOutputs("ClGatherWorkload", 2, 1);
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010041
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
Kevin May9f6862d2021-10-22 15:42:28 +010048 {
49 ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClGatherWorkload_configure");
50 m_Layer.configure(clCompileContext, &input, &indices, &output, aclAxis);
51 }
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010052};
53
54void ClGatherWorkload::Execute() const
55{
Keith Davisbcd860a2021-08-05 14:20:33 +010056 ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClGatherWorkload_Execute", this->GetGuid());
Teresa Charlin9ad2e5b2020-04-10 22:34:48 +010057 RunClFunction(m_Layer, CHECK_LOCATION());
58}
59} // namespace armnn