ArmNN
 24.08
NeonReduceWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "NeonReduceWorkload.hpp"
7 
10 
12 
13 #include "NeonWorkloadUtils.hpp"
14 
15 namespace armnn
16 {
17 using namespace armcomputetensorutils;
18 
20  const TensorInfo& output,
21  const ReduceDescriptor& descriptor)
22 {
23  if ( descriptor.m_vAxis.size()==1 || descriptor.m_vAxis.empty())
24  {
25  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
26  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
27 
28  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(),
29  input.GetNumDimensions(),
30  descriptor.m_vAxis);
31 
32  return arm_compute::NEReductionOperation::validate(&aclInputInfo,
33  &aclOutputInfo,
34  static_cast<unsigned int>(coords[0]),
36  descriptor.m_KeepDims);
37  }
38  else
39  {
40  // Validate layer if there are multiple axes.
41  arm_compute::Status status;
43  return status;
44  }
45 }
46 
49 {
50  // Report Profiling Details
51  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonReduceWorkload_Construct",
52  descriptor.m_Parameters,
53  info,
54  this->GetGuid());
55 
56  m_Data.ValidateInputsOutputs("NeonReduceWorkload", 1, 1);
57 
58  arm_compute::ITensor& input = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
59  arm_compute::ITensor& output = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
60 
61  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(input.info()->num_dimensions(),
62  info.m_InputTensorInfos[0].GetNumDimensions(),
64 
65  m_Layer.configure(&input,
66  &output,
67  static_cast<unsigned int>(coords[0]),
70 }
71 
73 {
74  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonReduceWorkload_Execute");
75  m_Layer.run();
76 }
77 
78 } //namespace armnn
IS_MULTI_AXES_REDUCE_SUPPORTED
#define IS_MULTI_AXES_REDUCE_SUPPORTED(func, input, desc, status)
Macro function check if layer with multiple axes is supported on each backend.
Definition: ArmComputeUtils.hpp:373
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:447
armnn::TensorInfo
Definition: Tensor.hpp:152
NeonTensorHandle.hpp
armnn::TensorInfo::GetNumDimensions
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:197
armnn::Coordinates
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
Definition: InternalTypes.hpp:15
armnn::ConvertReductionOperationToAcl
arm_compute::ReductionOperation ConvertReductionOperationToAcl(const ReduceDescriptor &descriptor)
Definition: ArmComputeUtils.hpp:306
armnn::NeonReduceWorkloadValidate
arm_compute::Status NeonReduceWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const ReduceDescriptor &descriptor)
Definition: NeonReduceWorkload.cpp:19
armnn::ReduceQueueDescriptor
Definition: WorkloadData.hpp:686
armnn::IAclTensorHandle
Definition: ArmComputeTensorHandle.hpp:16
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
NeonReduceWorkload.hpp
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
ArmComputeUtils.hpp
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::ReduceDescriptor::m_KeepDims
bool m_KeepDims
if true then output shape has no change.
Definition: Descriptors.hpp:1554
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::Status
Status
Definition: Types.hpp:42
armnn::NeonReduceWorkload::NeonReduceWorkload
NeonReduceWorkload(const ReduceQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: NeonReduceWorkload.cpp:47
armnn::BaseWorkload< ReduceQueueDescriptor >::m_Data
ReduceQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::ReduceDescriptor::m_vAxis
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
Definition: Descriptors.hpp:1556
NeonWorkloadUtils.hpp
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: NeonWorkloadUtils.hpp:33
armnn::ReduceDescriptor
A ReduceDescriptor for the REDUCE operators.
Definition: Descriptors.hpp:1538
armnn::NeonBaseWorkload
Definition: NeonBaseWorkload.hpp:13
armnn::NeonReduceWorkload::Execute
void Execute() const override
Definition: NeonReduceWorkload.cpp:72
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26