Teresa Charlin | 06145cc | 2022-05-05 15:31:30 +0100 | [diff] [blame] | 1 | // |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 2 | // Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved. |
Teresa Charlin | 06145cc | 2022-05-05 15:31:30 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonSqrtWorkload.hpp" |
| 7 | |
| 8 | #include "NeonWorkloadUtils.hpp" |
| 9 | |
| 10 | #include <aclCommon/ArmComputeTensorHandle.hpp> |
| 11 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 12 | #include <aclCommon/ArmComputeUtils.hpp> |
| 13 | #include <armnn/utility/PolymorphicDowncast.hpp> |
| 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | |
| 18 | arm_compute::Status NeonSqrtWorkloadValidate(const TensorInfo& input, const TensorInfo& output) |
| 19 | { |
| 20 | const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 21 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 22 | |
| 23 | ActivationDescriptor descriptor; |
| 24 | descriptor.m_Function = ActivationFunction::Sqrt; |
| 25 | const arm_compute::ActivationLayerInfo activationLayerInfo = |
| 26 | ConvertActivationDescriptorToAclActivationLayerInfo(descriptor); |
| 27 | |
| 28 | return arm_compute::NEActivationLayer::validate(&aclInput, &aclOutput, activationLayerInfo); |
| 29 | } |
| 30 | |
| 31 | NeonSqrtWorkload::NeonSqrtWorkload(const ElementwiseUnaryQueueDescriptor& descriptor, const WorkloadInfo& info) |
| 32 | : NeonBaseWorkload<ElementwiseUnaryQueueDescriptor>(descriptor, info) |
| 33 | { |
| 34 | ARMNN_ASSERT(descriptor.m_Parameters.m_Operation == UnaryOperation::Sqrt); |
| 35 | |
| 36 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonSqrtWorkload_Construct", |
| 37 | descriptor.m_Parameters, |
| 38 | info, |
| 39 | this->GetGuid()); |
| 40 | |
| 41 | m_Data.ValidateInputsOutputs("NeonSqrtWorkload", 1, 1); |
| 42 | |
| 43 | ActivationDescriptor activationDescriptor; |
| 44 | activationDescriptor.m_Function = ActivationFunction::Sqrt; |
| 45 | const arm_compute::ActivationLayerInfo activationLayerInfo = |
| 46 | ConvertActivationDescriptorToAclActivationLayerInfo(activationDescriptor); |
| 47 | |
| 48 | arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 49 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 50 | |
| 51 | m_SqrtLayer.configure(&input, &output, activationLayerInfo); |
| 52 | } |
| 53 | |
| 54 | void NeonSqrtWorkload::Execute() const |
| 55 | { |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 56 | ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonSqrtWorkload_Execute"); |
Teresa Charlin | 06145cc | 2022-05-05 15:31:30 +0100 | [diff] [blame] | 57 | m_SqrtLayer.run(); |
| 58 | } |
| 59 | |
| 60 | } // namespace armnn |