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 | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 32 | : BaseWorkload<GatherQueueDescriptor>(descriptor, info) |
| 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 | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 40 | 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 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 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 48 | m_Layer.configure(clCompileContext, &input, &indices, &output, aclAxis); |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | void ClGatherWorkload::Execute() const |
| 52 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 53 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClGatherWorkload_Execute", this->GetGuid()); |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 54 | RunClFunction(m_Layer, CHECK_LOCATION()); |
| 55 | } |
| 56 | } // namespace armnn |