blob: 6398b659467f5b925f6d2ce3ab82dd0f1731a713 [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
10#include <arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h>
telsoa014fcda012018-03-09 14:13:49 +000011
12namespace armnn
13{
14
telsoa01c577f2c2018-08-31 09:22:23 +010015arm_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 Kennedyb99480b2019-03-08 08:24:41 +000034NeonMultiplicationWorkload::NeonMultiplicationWorkload(const MultiplicationQueueDescriptor& descriptor,
35 const WorkloadInfo& info)
36 : BaseWorkload<MultiplicationQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000037{
Conor Kennedyb99480b2019-03-08 08:24:41 +000038 m_Data.ValidateInputsOutputs("NeonMultiplicationWorkload", 2, 1);
telsoa014fcda012018-03-09 14:13:49 +000039
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 Benthamd80a7122019-01-08 17:52:37 +000047 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());
telsoa014fcda012018-03-09 14:13:49 +000055}
56
Conor Kennedyb99480b2019-03-08 08:24:41 +000057void NeonMultiplicationWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000058{
Conor Kennedyb99480b2019-03-08 08:24:41 +000059 ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonMultiplicationWorkload_Execute");
Matthew Benthamd80a7122019-01-08 17:52:37 +000060 m_PixelWiseMultiplication->run();
telsoa014fcda012018-03-09 14:13:49 +000061}
62
63} //namespace armnn