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