Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +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 | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonGatherWorkload.hpp" |
| 7 | #include "NeonWorkloadUtils.hpp" |
| 8 | #include <armnn/utility/PolymorphicDowncast.hpp> |
| 9 | #include <aclCommon/ArmComputeUtils.hpp> |
| 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | arm_compute::Status NeonGatherWorkloadValidate(const TensorInfo& input, |
| 14 | const TensorInfo& indices, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 15 | const TensorInfo& output, |
| 16 | const GatherDescriptor& descriptor) |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 17 | { |
| 18 | const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input); |
| 19 | const arm_compute::TensorInfo aclIndices = BuildArmComputeTensorInfo(indices); |
| 20 | const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output); |
| 21 | |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 22 | int aclAxis = ComputeAclAxis(descriptor.m_Axis, input); |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 23 | |
| 24 | return arm_compute::NEGather::validate(&aclInput, &aclIndices, &aclOutput, aclAxis); |
| 25 | } |
| 26 | |
| 27 | NeonGatherWorkload::NeonGatherWorkload(const GatherQueueDescriptor& descriptor, |
| 28 | const WorkloadInfo& info) |
| 29 | : BaseWorkload<GatherQueueDescriptor>(descriptor, info) |
| 30 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 31 | // Report Profiling Details |
| 32 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonGatherWorkload_Construct", |
| 33 | descriptor.m_Parameters, |
| 34 | info, |
| 35 | this->GetGuid()); |
| 36 | |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 37 | m_Data.ValidateInputsOutputs("NeonGatherWorkload", 1, 1); |
| 38 | |
| 39 | arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 40 | arm_compute::ITensor& indices = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor(); |
| 41 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 42 | |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 43 | int aclAxis = ComputeAclAxis(descriptor.m_Parameters.m_Axis, info.m_InputTensorInfos[0]); |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 44 | |
| 45 | m_Layer.configure(&input, &indices, &output, aclAxis); |
| 46 | } |
| 47 | |
| 48 | void NeonGatherWorkload::Execute() const |
| 49 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 50 | ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonGatherWorkload_Execute", this->GetGuid()); |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 51 | m_Layer.run(); |
| 52 | } |
| 53 | } //namespace armnn |