xref: /aosp_15_r20/external/armnn/src/backends/cl/workloads/ClExpWorkload.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClExpWorkload.hpp"
7 
8 #include "ClWorkloadUtils.hpp"
9 
10 #include <aclCommon/ArmComputeTensorUtils.hpp>
11 #include <armnn/utility/PolymorphicDowncast.hpp>
12 
13 #include <cl/ClTensorHandle.hpp>
14 
15 namespace armnn
16 {
17 
ClExpWorkloadValidate(const TensorInfo & input,const TensorInfo & output)18 arm_compute::Status ClExpWorkloadValidate(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     return arm_compute::CLExpLayer::validate(&aclInput, &aclOutput);
24 }
25 
ClExpWorkload(const ElementwiseUnaryQueueDescriptor & descriptor,const WorkloadInfo & info,const arm_compute::CLCompileContext & clCompileContext)26 ClExpWorkload::ClExpWorkload(const ElementwiseUnaryQueueDescriptor& descriptor,
27                              const WorkloadInfo& info,
28                              const arm_compute::CLCompileContext& clCompileContext)
29     : ClBaseWorkload<ElementwiseUnaryQueueDescriptor>(descriptor, info)
30 {
31     // Report Profiling Details
32     ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClExpWorkload_Construct",
33                                          descriptor.m_Parameters,
34                                          info,
35                                          this->GetGuid());
36 
37     m_Data.ValidateInputsOutputs("ClExpWorkload", 1, 1);
38 
39     arm_compute::ICLTensor& input  = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
40     arm_compute::ICLTensor& output = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
41 
42     {
43         ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClExpWorkload_configure");
44         m_ExpLayer.configure(clCompileContext, &input, &output);
45     }
46 }
47 
Execute() const48 void ClExpWorkload::Execute() const
49 {
50     ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClExpWorkload_Execute", this->GetGuid());
51     RunClFunction(m_ExpLayer, CHECK_LOCATION());
52 }
53 
54 } // namespace armnn
55