ArmNN
 25.11
Loading...
Searching...
No Matches
ClSqrtWorkload.cpp
Go to the documentation of this file.
1//
2// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ClSqrtWorkload.hpp"
7
8#include "ClWorkloadUtils.hpp"
9
13
14#include <cl/ClTensorHandle.hpp>
15
16namespace armnn
17{
18
19arm_compute::Status ClSqrtWorkloadValidate(const TensorInfo& input, const TensorInfo& output)
20{
21 const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22 const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23
24 ActivationDescriptor descriptor;
26 const arm_compute::ActivationLayerInfo activationLayerInfo =
28
29 return arm_compute::CLActivationLayer::validate(&aclInput, &aclOutput, activationLayerInfo);
30}
31
33 const WorkloadInfo& info,
34 const arm_compute::CLCompileContext& clCompileContext)
36{
38 {
39 throw InvalidArgumentException("ClSqrtWorkload: The descriptor does not indicate a Sqrt operation.");
40 }
41
42 // Report Profiling Details
43 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClSqrtWorkload_Construct",
44 descriptor.m_Parameters,
45 info,
46 this->GetGuid());
47
48 m_Data.ValidateInputsOutputs("ClSqrtWorkload", 1, 1);
49
50 ActivationDescriptor activationDescriptor;
51 activationDescriptor.m_Function = ActivationFunction::Sqrt;
52 const arm_compute::ActivationLayerInfo activationLayerInfo =
54
55 arm_compute::ICLTensor& input = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
56 arm_compute::ICLTensor& output = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
57
58 {
59 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClSqrtWorkload_configure");
60 m_SqrtLayer.configure(clCompileContext, &input, &output, activationLayerInfo);
61 }
62}
63
65{
66 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClSqrtWorkload_Execute");
67 RunClFunction(m_SqrtLayer, CHECK_LOCATION());
68}
69
70} // namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
#define CHECK_LOCATION()
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
ClBaseWorkload(const ElementwiseUnaryQueueDescriptor &descriptor, const WorkloadInfo &info)
ClSqrtWorkload(const ElementwiseUnaryQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
virtual void Execute() const override
Copyright (c) 2021 ARM Limited and Contributors.
arm_compute::Status ClSqrtWorkloadValidate(const TensorInfo &input, const TensorInfo &output)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
DestType PolymorphicDowncast(SourceType *value)
Polymorphic downcast for build in pointers only.
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)
An ActivationDescriptor for the ActivationLayer.
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu,...
UnaryOperation m_Operation
Specifies the elementwiseUnary operation to execute.
Contains information about TensorInfos of a layer.