Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 3 | // 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 | |
| 11 | using namespace armnn::armcomputetensorutils; |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | arm_compute::Status ClGatherWorkloadValidate(const TensorInfo& input, |
| 16 | const TensorInfo& indices, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 17 | const TensorInfo& output, |
| 18 | const GatherDescriptor& descriptor) |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 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 | |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 24 | int aclAxis = ComputeAclAxis(descriptor.m_Axis, input); |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 25 | |
| 26 | return arm_compute::CLGather::validate(&aclInput, &aclIndices, &aclOutput, aclAxis); |
| 27 | } |
| 28 | |
| 29 | ClGatherWorkload::ClGatherWorkload(const GatherQueueDescriptor& descriptor, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 30 | const WorkloadInfo& info, |
| 31 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 32 | : ClBaseWorkload<GatherQueueDescriptor>(descriptor, info) |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 33 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 34 | // Report Profiling Details |
| 35 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClGatherWorkload_Construct", |
| 36 | descriptor.m_Parameters, |
| 37 | info, |
| 38 | this->GetGuid()); |
| 39 | |
Teresa Charlin | 2ea38c7 | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 40 | m_Data.ValidateInputsOutputs("ClGatherWorkload", 2, 1); |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 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 Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 46 | int aclAxis = ComputeAclAxis(descriptor.m_Parameters.m_Axis, info.m_InputTensorInfos[0]); |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 47 | |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 48 | { |
| 49 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClGatherWorkload_configure"); |
| 50 | m_Layer.configure(clCompileContext, &input, &indices, &output, aclAxis); |
| 51 | } |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | void ClGatherWorkload::Execute() const |
| 55 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 56 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClGatherWorkload_Execute", this->GetGuid()); |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 57 | RunClFunction(m_Layer, CHECK_LOCATION()); |
| 58 | } |
| 59 | } // namespace armnn |