Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClComparisonWorkload.hpp" |
| 7 | |
| 8 | #include "ClWorkloadUtils.hpp" |
| 9 | |
| 10 | #include <aclCommon/ArmComputeUtils.hpp> |
| 11 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 12 | |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 13 | #include <backendsCommon/TensorHandle.hpp> |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 14 | |
| 15 | #include <cl/ClLayerSupport.hpp> |
| 16 | #include <cl/ClTensorHandle.hpp> |
| 17 | #include <cl/ClLayerSupport.hpp> |
| 18 | |
| 19 | namespace armnn |
| 20 | { |
| 21 | |
| 22 | using namespace armcomputetensorutils; |
| 23 | |
| 24 | arm_compute::Status ClComparisonWorkloadValidate(const TensorInfo& input0, |
| 25 | const TensorInfo& input1, |
| 26 | const TensorInfo& output, |
| 27 | const ComparisonDescriptor& descriptor) |
| 28 | { |
| 29 | const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0); |
| 30 | const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1); |
| 31 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output); |
| 32 | |
| 33 | const arm_compute::ComparisonOperation comparisonOperation = ConvertComparisonOperationToAcl(descriptor); |
| 34 | |
| 35 | const arm_compute::Status aclStatus = arm_compute::CLComparison::validate(&aclInput0Info, |
| 36 | &aclInput1Info, |
| 37 | &aclOutputInfo, |
| 38 | comparisonOperation); |
| 39 | return aclStatus; |
| 40 | } |
| 41 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 42 | ClComparisonWorkload::ClComparisonWorkload(const ComparisonQueueDescriptor& descriptor, |
| 43 | const WorkloadInfo& info, |
| 44 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 45 | : BaseWorkload<ComparisonQueueDescriptor>(descriptor, info) |
| 46 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 47 | // Report Profiling Details |
| 48 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonComparisonWorkload_Construct", |
| 49 | descriptor.m_Parameters, |
| 50 | info, |
| 51 | this->GetGuid()); |
| 52 | |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 53 | m_Data.ValidateInputsOutputs("ClComparisonWorkload", 2, 1); |
| 54 | |
| 55 | arm_compute::ICLTensor& input0 = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 56 | arm_compute::ICLTensor& input1 = static_cast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor(); |
| 57 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 58 | |
| 59 | const arm_compute::ComparisonOperation comparisonOperation = ConvertComparisonOperationToAcl(m_Data.m_Parameters); |
| 60 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 61 | m_ComparisonLayer.configure(clCompileContext, &input0, &input1, &output, comparisonOperation); |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void ClComparisonWorkload::Execute() const |
| 65 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 66 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClComparisonWorkload_Execute", this->GetGuid()); |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 67 | RunClFunction(m_ComparisonLayer, CHECK_LOCATION()); |
| 68 | } |
| 69 | |
| 70 | } //namespace armnn |