ArmNN
 20.02
NeonMultiplicationWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "NeonWorkloadUtils.hpp"
9 
10 #include <arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h>
11 
12 namespace armnn
13 {
14 
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 
35  const WorkloadInfo& info)
36  : BaseWorkload<MultiplicationQueueDescriptor>(descriptor, info)
37 {
38  m_Data.ValidateInputsOutputs("NeonMultiplicationWorkload", 2, 1);
39 
40  arm_compute::ITensor& input1 = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
41  arm_compute::ITensor& input2 = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
42  arm_compute::ITensor& output = boost::polymorphic_downcast<IAclTensorHandle*>(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.
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());
55 }
56 
58 {
59  ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonMultiplicationWorkload_Execute");
60  m_PixelWiseMultiplication->run();
61 }
62 
63 } //namespace armnn
arm_compute::Status NeonMultiplicationWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
const MultiplicationQueueDescriptor m_Data
Definition: Workload.hpp:46
#define ARMNN_SCOPED_PROFILING_EVENT_NEON(name)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2020 ARM Limited.
NeonMultiplicationWorkload(const MultiplicationQueueDescriptor &descriptor, const WorkloadInfo &info)
Status
enumeration
Definition: Types.hpp:26
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs