blob: d813970901a7b15b4989d0422cced73a29410c81 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
Conor Kennedyb99480b2019-03-08 08:24:41 +00006#include "NeonMultiplicationWorkload.hpp"
telsoa014fcda012018-03-09 14:13:49 +00007
Matthew Benthamd80a7122019-01-08 17:52:37 +00008#include "NeonWorkloadUtils.hpp"
9
Jan Eilersbb446e52020-04-02 13:56:54 +010010#include <armnn/utility/PolymorphicDowncast.hpp>
11
Matthew Benthamd80a7122019-01-08 17:52:37 +000012#include <arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h>
telsoa014fcda012018-03-09 14:13:49 +000013
14namespace armnn
15{
16
telsoa01c577f2c2018-08-31 09:22:23 +010017arm_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 Kennedyb99480b2019-03-08 08:24:41 +000036NeonMultiplicationWorkload::NeonMultiplicationWorkload(const MultiplicationQueueDescriptor& descriptor,
37 const WorkloadInfo& info)
38 : BaseWorkload<MultiplicationQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000039{
Conor Kennedyb99480b2019-03-08 08:24:41 +000040 m_Data.ValidateInputsOutputs("NeonMultiplicationWorkload", 2, 1);
telsoa014fcda012018-03-09 14:13:49 +000041
Jan Eilersbb446e52020-04-02 13:56:54 +010042 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();
telsoa014fcda012018-03-09 14:13:49 +000045
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 Benthamd80a7122019-01-08 17:52:37 +000049 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());
telsoa014fcda012018-03-09 14:13:49 +000057}
58
Conor Kennedyb99480b2019-03-08 08:24:41 +000059void NeonMultiplicationWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000060{
Conor Kennedyb99480b2019-03-08 08:24:41 +000061 ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonMultiplicationWorkload_Execute");
Matthew Benthamd80a7122019-01-08 17:52:37 +000062 m_PixelWiseMultiplication->run();
telsoa014fcda012018-03-09 14:13:49 +000063}
64
65} //namespace armnn