ArmNN
 20.05
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 
11 
12 #include <arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h>
13 
14 namespace armnn
15 {
16 
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 
37  const WorkloadInfo& info)
38  : BaseWorkload<MultiplicationQueueDescriptor>(descriptor, info)
39 {
40  m_Data.ValidateInputsOutputs("NeonMultiplicationWorkload", 2, 1);
41 
42  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();
45 
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.
49  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());
57 }
58 
60 {
61  ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonMultiplicationWorkload_Execute");
62  m_PixelWiseMultiplication->run();
63 }
64 
65 } //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