telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 6 | #include "NeonMultiplicationWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 8 | #include "NeonWorkloadUtils.hpp" |
| 9 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 10 | #include <armnn/utility/PolymorphicDowncast.hpp> |
| 11 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 12 | #include <arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 17 | arm_compute::Status NeonMultiplicationWorkloadValidate(const TensorInfo& input0, |
| 18 | const TensorInfo& input1, |
| 19 | const TensorInfo& output) |
| 20 | { |
| 21 | const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0); |
| 22 | const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1); |
| 23 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 24 | |
| 25 | // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it, |
| 26 | // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be |
| 27 | // ignored for F32 tensors. |
| 28 | return arm_compute::NEPixelWiseMultiplication::validate(&aclInput1, |
| 29 | &aclInput2, |
| 30 | &aclOutput, |
| 31 | 1.0f, |
| 32 | arm_compute::ConvertPolicy::SATURATE, |
| 33 | arm_compute::RoundingPolicy::TO_ZERO); |
| 34 | } |
| 35 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 36 | NeonMultiplicationWorkload::NeonMultiplicationWorkload(const MultiplicationQueueDescriptor& descriptor, |
| 37 | const WorkloadInfo& info) |
| 38 | : BaseWorkload<MultiplicationQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 40 | m_Data.ValidateInputsOutputs("NeonMultiplicationWorkload", 2, 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 42 | arm_compute::ITensor& input1 = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 43 | arm_compute::ITensor& input2 = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor(); |
| 44 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | |
| 46 | // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it, |
| 47 | // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be |
| 48 | // ignored for F32 tensors. |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 49 | auto layer = std::make_unique<arm_compute::NEPixelWiseMultiplication>(); |
| 50 | layer->configure(&input1, |
| 51 | &input2, |
| 52 | &output, |
| 53 | 1.0f, |
| 54 | arm_compute::ConvertPolicy::SATURATE, |
| 55 | arm_compute::RoundingPolicy::TO_ZERO); |
| 56 | m_PixelWiseMultiplication.reset(layer.release()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 57 | } |
| 58 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 59 | void NeonMultiplicationWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 61 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonMultiplicationWorkload_Execute"); |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 62 | m_PixelWiseMultiplication->run(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | } //namespace armnn |