blob: c4241ece19b8752db5ee80ae8dac2269f7fbc994 [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
arovir019e53a352018-08-31 15:26:35 +01006#include "NeonMultiplicationFloatWorkload.hpp"
telsoa014fcda012018-03-09 14:13:49 +00007
8
9namespace armnn
10{
11
telsoa01c577f2c2018-08-31 09:22:23 +010012arm_compute::Status NeonMultiplicationWorkloadValidate(const TensorInfo& input0,
13 const TensorInfo& input1,
14 const TensorInfo& output)
15{
16 const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
17 const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
18 const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
19
20 // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it,
21 // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be
22 // ignored for F32 tensors.
23 return arm_compute::NEPixelWiseMultiplication::validate(&aclInput1,
24 &aclInput2,
25 &aclOutput,
26 1.0f,
27 arm_compute::ConvertPolicy::SATURATE,
28 arm_compute::RoundingPolicy::TO_ZERO);
29}
30
arovir019e53a352018-08-31 15:26:35 +010031NeonMultiplicationFloatWorkload::NeonMultiplicationFloatWorkload(const MultiplicationQueueDescriptor& descriptor,
32 const WorkloadInfo& info)
telsoa01c577f2c2018-08-31 09:22:23 +010033 : FloatWorkload<MultiplicationQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000034{
arovir019e53a352018-08-31 15:26:35 +010035 m_Data.ValidateInputsOutputs("NeonMultiplicationFloatWorkload", 2, 1);
telsoa014fcda012018-03-09 14:13:49 +000036
37 arm_compute::ITensor& input1 = boost::polymorphic_downcast<INeonTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
38 arm_compute::ITensor& input2 = boost::polymorphic_downcast<INeonTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
39 arm_compute::ITensor& output = boost::polymorphic_downcast<INeonTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
40
41 // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it,
42 // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be
43 // ignored for F32 tensors.
44 m_PixelWiseMultiplication.configure(&input1,
45 &input2,
46 &output,
47 1.0f,
48 arm_compute::ConvertPolicy::SATURATE,
49 arm_compute::RoundingPolicy::TO_ZERO);
50}
51
arovir019e53a352018-08-31 15:26:35 +010052void NeonMultiplicationFloatWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000053{
arovir019e53a352018-08-31 15:26:35 +010054 ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonMultiplicationFloatWorkload_Execute");
telsoa014fcda012018-03-09 14:13:49 +000055 m_PixelWiseMultiplication.run();
56}
57
58} //namespace armnn
59
60