diff options
author | Teresa Charlin <teresa.charlinreyes@arm.com> | 2022-05-05 16:11:36 +0100 |
---|---|---|
committer | TeresaARM <teresa.charlinreyes@arm.com> | 2022-05-06 13:47:10 +0000 |
commit | aac61129e4317000c46e37063b010851b0e17d27 (patch) | |
tree | 8c4d07b391609e9c84d23261ace408c7e54b2316 /src/backends/cl/workloads/ClSqrtWorkload.cpp | |
parent | aa8051015a5de37438ef5526417156e51296d0f4 (diff) | |
download | armnn-aac61129e4317000c46e37063b010851b0e17d27.tar.gz |
IVGCVSW-6936 Add SQRT support to CL
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: Ib90bade63cd0437329c690b09cf719a2e2bd06a4
Diffstat (limited to 'src/backends/cl/workloads/ClSqrtWorkload.cpp')
-rw-r--r-- | src/backends/cl/workloads/ClSqrtWorkload.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/backends/cl/workloads/ClSqrtWorkload.cpp b/src/backends/cl/workloads/ClSqrtWorkload.cpp new file mode 100644 index 0000000000..b78c114cf7 --- /dev/null +++ b/src/backends/cl/workloads/ClSqrtWorkload.cpp @@ -0,0 +1,67 @@ +// +// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "ClSqrtWorkload.hpp" + +#include "ClWorkloadUtils.hpp" + +#include <aclCommon/ArmComputeTensorUtils.hpp> +#include <aclCommon/ArmComputeUtils.hpp> +#include <armnn/utility/PolymorphicDowncast.hpp> + +#include <cl/ClTensorHandle.hpp> + +namespace armnn +{ + +arm_compute::Status ClSqrtWorkloadValidate(const TensorInfo& input, const TensorInfo& output) +{ + const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); + const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); + + ActivationDescriptor descriptor; + descriptor.m_Function = ActivationFunction::Sqrt; + const arm_compute::ActivationLayerInfo activationLayerInfo = + ConvertActivationDescriptorToAclActivationLayerInfo(descriptor); + + return arm_compute::CLActivationLayer::validate(&aclInput, &aclOutput, activationLayerInfo); +} + +ClSqrtWorkload::ClSqrtWorkload(const ElementwiseUnaryQueueDescriptor& descriptor, + const WorkloadInfo& info, + const arm_compute::CLCompileContext& clCompileContext) + : ClBaseWorkload<ElementwiseUnaryQueueDescriptor>(descriptor, info) +{ + ARMNN_ASSERT(descriptor.m_Parameters.m_Operation == UnaryOperation::Sqrt); + + // Report Profiling Details + ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClSqrtWorkload_Construct", + descriptor.m_Parameters, + info, + this->GetGuid()); + + m_Data.ValidateInputsOutputs("ClSqrtWorkload", 1, 1); + + ActivationDescriptor activationDescriptor; + activationDescriptor.m_Function = ActivationFunction::Sqrt; + const arm_compute::ActivationLayerInfo activationLayerInfo = + ConvertActivationDescriptorToAclActivationLayerInfo(activationDescriptor); + + arm_compute::ICLTensor& input = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); + arm_compute::ICLTensor& output = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); + + { + ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClSqrtWorkload_configure"); + m_SqrtLayer.configure(clCompileContext, &input, &output, activationLayerInfo); + } +} + +void ClSqrtWorkload::Execute() const +{ + ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClSqrtWorkload_Execute", this->GetGuid()); + RunClFunction(m_SqrtLayer, CHECK_LOCATION()); +} + +} // namespace armnn |