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" |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 10 | #include <backendsCommon/CpuTensorHandle.hpp> |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 11 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 12 | #include <arm_compute/runtime/NEON/functions/NEArithmeticSubtraction.h> |
| 13 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | arm_compute::Status NeonSubtractionWorkloadValidate(const TensorInfo& input0, |
| 18 | const TensorInfo& input1, |
| 19 | const TensorInfo& output) |
| 20 | { |
| 21 | const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0); |
| 22 | const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1); |
| 23 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 24 | |
| 25 | return arm_compute::NEArithmeticSubtraction::validate(&aclInput0, |
| 26 | &aclInput1, |
| 27 | &aclOutput, |
| 28 | arm_compute::ConvertPolicy::SATURATE); |
| 29 | } |
| 30 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 31 | NeonSubtractionWorkload::NeonSubtractionWorkload(const SubtractionQueueDescriptor& descriptor, |
| 32 | const WorkloadInfo& info) |
| 33 | : BaseWorkload<SubtractionQueueDescriptor>(descriptor, info) |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 34 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 35 | m_Data.ValidateInputsOutputs("NeonSubtractionWorkload", 2, 1); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 36 | |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 37 | arm_compute::ITensor& input1 = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 38 | arm_compute::ITensor& input2 = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor(); |
| 39 | arm_compute::ITensor& output = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 40 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 41 | auto layer = std::make_unique<arm_compute::NEArithmeticSubtraction>(); |
| 42 | layer->configure(&input1, &input2, &output, arm_compute::ConvertPolicy::SATURATE); |
| 43 | m_SubLayer.reset(layer.release()); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 46 | void NeonSubtractionWorkload::Execute() const |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 47 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 48 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSubtractionWorkload_Execute"); |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 49 | m_SubLayer->run(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | } //namespace armnn |