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> |
| 9 | #include <backendsCommon/CpuTensorHandle.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, |
| 22 | const WorkloadInfo& info) |
| 23 | : BaseWorkload<SubtractionQueueDescriptor>(descriptor, info) |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 24 | { |
David Beck | 0a710c4 | 2018-09-11 15:21:14 +0100 | [diff] [blame] | 25 | this->m_Data.ValidateInputsOutputs("ClSubtractionWorkload", 2, 1); |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 26 | |
| 27 | arm_compute::ICLTensor& input0 = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor(); |
| 28 | arm_compute::ICLTensor& input1 = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[1])->GetTensor(); |
| 29 | 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] | 30 | |
| 31 | const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor); |
| 32 | |
| 33 | m_Layer.configure(&input0, &input1, &output, g_AclConvertPolicy, activationInfo); |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 34 | } |
| 35 | |
Matthew Bentham | 092b304 | 2018-10-01 16:39:28 +0100 | [diff] [blame] | 36 | void ClSubtractionWorkload::Execute() const |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 37 | { |
David Beck | 0a710c4 | 2018-09-11 15:21:14 +0100 | [diff] [blame] | 38 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClSubtractionWorkload_Execute"); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 39 | RunClFunction(m_Layer, CHECK_LOCATION()); |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 40 | } |
| 41 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 42 | arm_compute::Status ClSubtractionValidate(const TensorInfo& input0, |
| 43 | const TensorInfo& input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 44 | const TensorInfo& output, |
| 45 | const ActivationDescriptor* activationDescriptor) |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 46 | { |
| 47 | const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0); |
| 48 | const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1); |
| 49 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output); |
| 50 | |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 51 | const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo( |
| 52 | activationDescriptor); |
| 53 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 54 | const arm_compute::Status aclStatus = arm_compute::CLArithmeticSubtraction::validate(&aclInput0Info, |
| 55 | &aclInput1Info, |
| 56 | &aclOutputInfo, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 57 | g_AclConvertPolicy, |
| 58 | activationInfo); |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 59 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 60 | return aclStatus; |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | } //namespace armnn |