ArmNN
 23.05
NeonDetectionPostProcessWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "NeonWorkloadUtils.hpp"
9 
13 
14 namespace armnn
15 {
16 
17 arm_compute::DetectionPostProcessLayerInfo MakeInfo(const DetectionPostProcessDescriptor& descriptor)
18 {
19  return arm_compute::DetectionPostProcessLayerInfo(descriptor.m_MaxDetections,
20  descriptor.m_MaxClassesPerDetection,
21  descriptor.m_NmsScoreThreshold,
22  descriptor.m_NmsIouThreshold,
23  descriptor.m_NumClasses,
24  { descriptor.m_ScaleX,
25  descriptor.m_ScaleY,
26  descriptor.m_ScaleW,
27  descriptor.m_ScaleH },
28  descriptor.m_UseRegularNms,
29  descriptor.m_DetectionsPerClass);
30 }
31 
33  const TensorInfo& scores,
34  const TensorInfo& anchors,
35  const TensorInfo& detectionBoxes,
36  const TensorInfo& detectionClasses,
37  const TensorInfo& detectionScores,
38  const TensorInfo& numDetections,
39  const DetectionPostProcessDescriptor &descriptor)
40 {
41  arm_compute::DetectionPostProcessLayerInfo info = MakeInfo(descriptor);
42 
43  const arm_compute::TensorInfo aclBoxEncodings =
44  armcomputetensorutils::BuildArmComputeTensorInfo(boxEncodings);
45 
46  const arm_compute::TensorInfo aclScores =
47  armcomputetensorutils::BuildArmComputeTensorInfo(scores);
48 
49  const arm_compute::TensorInfo aclAnchors =
50  armcomputetensorutils::BuildArmComputeTensorInfo(anchors);
51 
52  arm_compute::TensorInfo aclDetectionBoxes =
53  armcomputetensorutils::BuildArmComputeTensorInfo(detectionBoxes);
54 
55  arm_compute::TensorInfo aclDetectionClasses =
56  armcomputetensorutils::BuildArmComputeTensorInfo(detectionClasses);
57 
58  arm_compute::TensorInfo aclDetectionScores =
59  armcomputetensorutils::BuildArmComputeTensorInfo(detectionScores);
60 
61  arm_compute::TensorInfo aclNumDetections =
62  armcomputetensorutils::BuildArmComputeTensorInfo(numDetections);
63 
64  return arm_compute::NEDetectionPostProcessLayer::validate(
65  &aclBoxEncodings,
66  &aclScores,
67  &aclAnchors,
68  &aclDetectionBoxes,
69  &aclDetectionClasses,
70  &aclDetectionScores,
71  &aclNumDetections,
72  info);
73 }
74 
76  const DetectionPostProcessQueueDescriptor& descriptor,
77  const WorkloadInfo& info)
79 {
80  // Report Profiling Details
81  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonDetectionPostProcessWorkload_Construct",
82  descriptor.m_Parameters,
83  info,
84  this->GetGuid());
85 
86  m_Anchors = std::make_unique<arm_compute::Tensor>();
87  BuildArmComputeTensor(*m_Anchors, descriptor.m_Anchors->GetTensorInfo());
88 
89  arm_compute::DetectionPostProcessLayerInfo di = MakeInfo(m_Data.m_Parameters);
90 
91  auto AclTensorRef = [](ITensorHandle* tensor) -> arm_compute::ITensor&
92  {
93  return PolymorphicDowncast<IAclTensorHandle*>(tensor)->GetTensor();
94  };
95 
96  arm_compute::ITensor& boxEncodings = AclTensorRef(m_Data.m_Inputs[0]);
97  arm_compute::ITensor& scores = AclTensorRef(m_Data.m_Inputs[1]);
98 
99  arm_compute::ITensor& detectionBoxes = AclTensorRef(m_Data.m_Outputs[0]);
100  arm_compute::ITensor& detectionClasses = AclTensorRef(m_Data.m_Outputs[1]);
101  arm_compute::ITensor& detectionScores = AclTensorRef(m_Data.m_Outputs[2]);
102  arm_compute::ITensor& numDetections = AclTensorRef(m_Data.m_Outputs[3]);
103 
104  m_Func.configure(&boxEncodings, &scores, m_Anchors.get(),
105  &detectionBoxes, &detectionClasses, &detectionScores, &numDetections,
106  di);
107 
109 }
110 
112 {
113  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonDetectionPostProcessWorkload_Execute", this->GetGuid());
114  m_Func.run();
115 }
116 
117 } // namespace armnn
armnn::BaseWorkload< DetectionPostProcessQueueDescriptor >::GetGuid
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:61
armnn::NeonDetectionPostProcessWorkload::Execute
virtual void Execute() const override
Definition: NeonDetectionPostProcessWorkload.cpp:111
armnn::NeonDetectionPostProcessValidate
arm_compute::Status NeonDetectionPostProcessValidate(const TensorInfo &boxEncodings, const TensorInfo &scores, const TensorInfo &anchors, const TensorInfo &detectionBoxes, const TensorInfo &detectionClasses, const TensorInfo &detectionScores, const TensorInfo &numDetections, const DetectionPostProcessDescriptor &descriptor)
Definition: NeonDetectionPostProcessWorkload.cpp:32
armnn::DetectionPostProcessQueueDescriptor
Definition: WorkloadData.hpp:234
armnn::MakeInfo
arm_compute::DetectionPostProcessLayerInfo MakeInfo(const DetectionPostProcessDescriptor &descriptor)
Definition: NeonDetectionPostProcessWorkload.cpp:17
PolymorphicDowncast.hpp
armnn::DetectionPostProcessDescriptor::m_MaxDetections
uint32_t m_MaxDetections
Maximum numbers of detections.
Definition: Descriptors.hpp:733
armnn::NeonDetectionPostProcessWorkload::NeonDetectionPostProcessWorkload
NeonDetectionPostProcessWorkload(const DetectionPostProcessQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: NeonDetectionPostProcessWorkload.cpp:75
armnn::DetectionPostProcessQueueDescriptor::m_Anchors
const ConstTensorHandle * m_Anchors
Definition: WorkloadData.hpp:241
NeonDetectionPostProcessWorkload.hpp
armnn::BaseWorkload< DetectionPostProcessQueueDescriptor >::m_Data
DetectionPostProcessQueueDescriptor m_Data
Definition: Workload.hpp:83
armnn::DetectionPostProcessDescriptor::m_NmsScoreThreshold
float m_NmsScoreThreshold
NMS score threshold.
Definition: Descriptors.hpp:739
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::DetectionPostProcessDescriptor::m_DetectionsPerClass
uint32_t m_DetectionsPerClass
Detections per classes, used in Regular NMS.
Definition: Descriptors.hpp:737
armnn::InitializeArmComputeTensorData
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, TensorInfo tensorInfo, const ITensorHandle *handle)
Definition: NeonWorkloadUtils.hpp:60
armnn::ITensorHandle
Definition: ITensorHandle.hpp:15
armnn::DetectionPostProcessDescriptor
Definition: Descriptors.hpp:701
ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)
Definition: NeonWorkloadUtils.hpp:24
ArmComputeTensorUtils.hpp
armnn::TensorInfo
Definition: Tensor.hpp:152
NeonWorkloadUtils.hpp
armnn::Status
Status
Definition: Types.hpp:42
armnn::ConstTensorHandle::GetTensorInfo
const TensorInfo & GetTensorInfo() const
Definition: TensorHandle.hpp:40
ArmComputeTensorHandle.hpp
armnn::DetectionPostProcessDescriptor::m_NumClasses
uint32_t m_NumClasses
Number of classes.
Definition: Descriptors.hpp:743
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::DetectionPostProcessDescriptor::m_MaxClassesPerDetection
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
Definition: Descriptors.hpp:735
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::NeonBaseWorkload
Definition: NeonBaseWorkload.hpp:13
armnn::DetectionPostProcessDescriptor::m_NmsIouThreshold
float m_NmsIouThreshold
Intersection over union threshold.
Definition: Descriptors.hpp:741
armnn::DetectionPostProcessDescriptor::m_UseRegularNms
bool m_UseRegularNms
Use Regular NMS.
Definition: Descriptors.hpp:745
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::BoostLogSeverityMapping::info
@ info