David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
David Beck | 0a710c4 | 2018-09-11 15:21:14 +0100 | [diff] [blame] | 6 | #include "ClSubtractionWorkload.hpp" |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 7 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 8 | #include <cl/ClTensorHandle.hpp> |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 9 | #include <backendsCommon/TensorHandle.hpp> |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 10 | #include <aclCommon/ArmComputeUtils.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 11 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 12 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 13 | #include "ClWorkloadUtils.hpp" |
| 14 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 15 | namespace armnn |
| 16 | { |
| 17 | using namespace armcomputetensorutils; |
| 18 | |
| 19 | static constexpr arm_compute::ConvertPolicy g_AclConvertPolicy = arm_compute::ConvertPolicy::SATURATE; |
| 20 | |
Matthew Bentham | 092b304 | 2018-10-01 16:39:28 +0100 | [diff] [blame] | 21 | ClSubtractionWorkload::ClSubtractionWorkload(const SubtractionQueueDescriptor& descriptor, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 22 | const WorkloadInfo& info, |
| 23 | const arm_compute::CLCompileContext& clCompileContext) |
Matthew Bentham | 092b304 | 2018-10-01 16:39:28 +0100 | [diff] [blame] | 24 | : BaseWorkload<SubtractionQueueDescriptor>(descriptor, info) |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 25 | { |
David Beck | 0a710c4 | 2018-09-11 15:21:14 +0100 | [diff] [blame] | 26 | this->m_Data.ValidateInputsOutputs("ClSubtractionWorkload", 2, 1); |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 27 | |
| 28 | arm_compute::ICLTensor& input0 = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor(); |
| 29 | arm_compute::ICLTensor& input1 = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[1])->GetTensor(); |
| 30 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(this->m_Data.m_Outputs[0])->GetTensor(); |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 31 | |
| 32 | const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor); |
| 33 | |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 34 | { |
| 35 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClSubtractionWorkload_configure"); |
| 36 | m_Layer.configure(clCompileContext, &input0, &input1, &output, g_AclConvertPolicy, activationInfo); |
| 37 | } |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 38 | } |
| 39 | |
Matthew Bentham | 092b304 | 2018-10-01 16:39:28 +0100 | [diff] [blame] | 40 | void ClSubtractionWorkload::Execute() const |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 41 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 42 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClSubtractionWorkload_Execute", this->GetGuid()); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 43 | RunClFunction(m_Layer, CHECK_LOCATION()); |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 44 | } |
| 45 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 46 | arm_compute::Status ClSubtractionValidate(const TensorInfo& input0, |
| 47 | const TensorInfo& input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 48 | const TensorInfo& output, |
| 49 | const ActivationDescriptor* activationDescriptor) |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 50 | { |
| 51 | const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0); |
| 52 | const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1); |
| 53 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output); |
| 54 | |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 55 | const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo( |
| 56 | activationDescriptor); |
| 57 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 58 | const arm_compute::Status aclStatus = arm_compute::CLArithmeticSubtraction::validate(&aclInput0Info, |
| 59 | &aclInput1Info, |
| 60 | &aclOutputInfo, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 61 | g_AclConvertPolicy, |
| 62 | activationInfo); |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 63 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 64 | return aclStatus; |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | } //namespace armnn |