1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "ClActivationWorkload.hpp"
7
8 #include "ClWorkloadUtils.hpp"
9
10 #include <armnn/backends/TensorHandle.hpp>
11 #include <cl/ClLayerSupport.hpp>
12 #include <cl/ClTensorHandle.hpp>
13 #include <aclCommon/ArmComputeUtils.hpp>
14
15 namespace armnn
16 {
ClActivationWorkloadValidate(const TensorInfo & input,const TensorInfo & output,const ActivationDescriptor & descriptor)17 arm_compute::Status ClActivationWorkloadValidate(const TensorInfo& input,
18 const TensorInfo& output,
19 const ActivationDescriptor& descriptor)
20 {
21 const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22 const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23
24 const arm_compute::ActivationLayerInfo activationLayerInfo =
25 ConvertActivationDescriptorToAclActivationLayerInfo(descriptor);
26
27 return arm_compute::CLActivationLayer::validate(&aclInput,
28 &aclOutput,
29 activationLayerInfo);
30 }
31
ClActivationWorkload(const ActivationQueueDescriptor & descriptor,const WorkloadInfo & info,const arm_compute::CLCompileContext & clCompileContext)32 ClActivationWorkload::ClActivationWorkload(const ActivationQueueDescriptor& descriptor,
33 const WorkloadInfo& info,
34 const arm_compute::CLCompileContext& clCompileContext)
35 : ClBaseWorkload<ActivationQueueDescriptor>(descriptor, info)
36 {
37 // Report Profiling Details
38 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClActivationWorkload_Construct",
39 descriptor.m_Parameters,
40 info,
41 this->GetGuid());
42
43 m_Data.ValidateInputsOutputs("ClActivationWorkload", 1, 1);
44
45 const arm_compute::ActivationLayerInfo activationLayerInfo =
46 ConvertActivationDescriptorToAclActivationLayerInfo(m_Data.m_Parameters);
47
48 arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
49 arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
50 {
51 ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClActivationWorkload_configure");
52 m_ActivationLayer.configure(clCompileContext, &input, &output, activationLayerInfo);
53 }
54 }
55
Execute() const56 void ClActivationWorkload::Execute() const
57 {
58 ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClActivationWorkload_Execute", this->GetGuid());
59 RunClFunction(m_ActivationLayer, CHECK_LOCATION());
60 }
61
62 } //namespace armnn
63