telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 98b0dcb | 2022-01-18 22:09:29 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 6 | #include "ClActivationWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 8 | #include "ClWorkloadUtils.hpp" |
| 9 | |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 10 | #include <armnn/backends/TensorHandle.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 11 | #include <cl/ClLayerSupport.hpp> |
| 12 | #include <cl/ClTensorHandle.hpp> |
| 13 | #include <aclCommon/ArmComputeUtils.hpp> |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 14 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | namespace armnn |
| 16 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 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 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 27 | return arm_compute::CLActivationLayer::validate(&aclInput, |
| 28 | &aclOutput, |
| 29 | activationLayerInfo); |
| 30 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 31 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 32 | ClActivationWorkload::ClActivationWorkload(const ActivationQueueDescriptor& descriptor, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 33 | const WorkloadInfo& info, |
| 34 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 98b0dcb | 2022-01-18 22:09:29 +0000 | [diff] [blame] | 35 | : ClBaseWorkload<ActivationQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 37 | // Report Profiling Details |
| 38 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClActivationWorkload_Construct", |
| 39 | descriptor.m_Parameters, |
| 40 | info, |
| 41 | this->GetGuid()); |
| 42 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 43 | m_Data.ValidateInputsOutputs("ClActivationWorkload", 1, 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | |
| 45 | const arm_compute::ActivationLayerInfo activationLayerInfo = |
| 46 | ConvertActivationDescriptorToAclActivationLayerInfo(m_Data.m_Parameters); |
| 47 | |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 48 | arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 49 | arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 50 | { |
| 51 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClActivationWorkload_configure"); |
| 52 | m_ActivationLayer.configure(clCompileContext, &input, &output, activationLayerInfo); |
| 53 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 56 | void ClActivationWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 57 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 58 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClActivationWorkload_Execute", this->GetGuid()); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 59 | RunClFunction(m_ActivationLayer, CHECK_LOCATION()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 62 | } //namespace armnn |