David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 6 | #include "NeonSubtractionWorkload.hpp" |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 7 | |
| 8 | #include "NeonWorkloadUtils.hpp" |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 9 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 11 | #include <aclCommon/ArmComputeUtils.hpp> |
| 12 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 13 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 14 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 15 | #include <backendsCommon/CpuTensorHandle.hpp> |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 16 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 17 | #include <arm_compute/runtime/NEON/functions/NEArithmeticSubtraction.h> |
| 18 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 19 | namespace armnn |
| 20 | { |
| 21 | |
| 22 | arm_compute::Status NeonSubtractionWorkloadValidate(const TensorInfo& input0, |
| 23 | const TensorInfo& input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 24 | const TensorInfo& output, |
| 25 | const ActivationDescriptor* activationDescriptor) |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 26 | { |
| 27 | const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0); |
| 28 | const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1); |
| 29 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 30 | |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 31 | const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo( |
| 32 | activationDescriptor); |
| 33 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 34 | return arm_compute::NEArithmeticSubtraction::validate(&aclInput0, |
| 35 | &aclInput1, |
| 36 | &aclOutput, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 37 | arm_compute::ConvertPolicy::SATURATE, |
| 38 | activationInfo); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 39 | } |
| 40 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 41 | NeonSubtractionWorkload::NeonSubtractionWorkload(const SubtractionQueueDescriptor& descriptor, |
| 42 | const WorkloadInfo& info) |
| 43 | : BaseWorkload<SubtractionQueueDescriptor>(descriptor, info) |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 44 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 45 | m_Data.ValidateInputsOutputs("NeonSubtractionWorkload", 2, 1); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 46 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 47 | arm_compute::ITensor& input1 = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 48 | arm_compute::ITensor& input2 = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor(); |
| 49 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 50 | |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 51 | const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor); |
| 52 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 53 | auto layer = std::make_unique<arm_compute::NEArithmeticSubtraction>(); |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 54 | layer->configure(&input1, &input2, &output, arm_compute::ConvertPolicy::SATURATE, activationInfo); |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 55 | m_SubLayer.reset(layer.release()); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 56 | } |
| 57 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 58 | void NeonSubtractionWorkload::Execute() const |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 59 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 60 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSubtractionWorkload_Execute"); |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 61 | m_SubLayer->run(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | } //namespace armnn |