From ae050524109f1ce827962665436ef7430f2ac479 Mon Sep 17 00:00:00 2001 From: David Monahan Date: Wed, 22 Mar 2023 16:48:58 +0000 Subject: IVGCVSW-7255 Update Doxygen Documentation and publish on GitHub. * Updating Doxygen documentation for 23.02 release. Signed-off-by: David Monahan Change-Id: I545574ff7664b4595d2fe6a91a3c35d2ad55df82 --- ..._detection_post_process_layer_8cpp_source.xhtml | 240 +++++++++++++++------ 1 file changed, 174 insertions(+), 66 deletions(-) (limited to '23.02/_detection_post_process_layer_8cpp_source.xhtml') diff --git a/23.02/_detection_post_process_layer_8cpp_source.xhtml b/23.02/_detection_post_process_layer_8cpp_source.xhtml index c08d7d3b70..c9ea73109f 100644 --- a/23.02/_detection_post_process_layer_8cpp_source.xhtml +++ b/23.02/_detection_post_process_layer_8cpp_source.xhtml @@ -8,7 +8,7 @@ - + ArmNN: src/armnn/layers/DetectionPostProcessLayer.cpp Source File @@ -19,9 +19,6 @@ - @@ -30,7 +27,8 @@ extensions: ["tex2jax.js"], jax: ["input/TeX","output/HTML-CSS"], }); - + + @@ -51,18 +49,21 @@ - + +/* @license-end */
@@ -76,7 +77,9 @@ $(function() {
@@ -98,71 +101,176 @@ $(document).ready(function(){initNavTree('_detection_post_process_layer_8cpp_sou
DetectionPostProcessLayer.cpp
-Go to the documentation of this file.
1 //
2 // Copyright © 2017-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "LayerCloneBase.hpp"
9 
10 #include <armnn/TypesUtils.hpp>
14 
15 namespace armnn
16 {
17 
20 {
21 }
22 
23 std::unique_ptr<IWorkload> DetectionPostProcessLayer::CreateWorkload(const armnn::IWorkloadFactory& factory) const
24 {
26  descriptor.m_Anchors = m_Anchors.get();
27  SetAdditionalInfo(descriptor);
28 
29  return factory.CreateWorkload(LayerType::DetectionPostProcess, descriptor, PrepInfoAndDesc(descriptor));
30 }
31 
33 {
34  auto layer = CloneBase<DetectionPostProcessLayer>(graph, m_Param, GetName());
35  layer->m_Anchors = m_Anchors ? m_Anchors : nullptr;
36  return std::move(layer);
37 }
38 
40 {
42 
43  const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
44 
46 
47  // on this level constant data should not be released.
48  ARMNN_ASSERT_MSG(m_Anchors != nullptr, "DetectionPostProcessLayer: Anchors data should not be null.");
49 
50  ARMNN_ASSERT_MSG(GetNumOutputSlots() == 4, "DetectionPostProcessLayer: The layer should return 4 outputs.");
51 
52  std::vector<TensorShape> inferredShapes = InferOutputShapes(
55 
56  ARMNN_ASSERT(inferredShapes.size() == 4);
57  ARMNN_ASSERT(inferredShapes[0].GetDimensionality() == Dimensionality::Specified);
58  ARMNN_ASSERT(inferredShapes[1].GetDimensionality() == Dimensionality::Specified);
59  ARMNN_ASSERT(inferredShapes[2].GetDimensionality() == Dimensionality::Specified);
60  ARMNN_ASSERT(inferredShapes[3].GetDimensionality() == Dimensionality::Specified);
61 
62  ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "DetectionPostProcessLayer");
63 
65  inferredShapes[1],
67  "DetectionPostProcessLayer", 1);
68 
70  inferredShapes[2],
72  "DetectionPostProcessLayer", 2);
73 
75  inferredShapes[3],
77  "DetectionPostProcessLayer", 3);
78 }
79 
80 std::vector<TensorShape> DetectionPostProcessLayer::InferOutputShapes(const std::vector<TensorShape>&) const
81 {
82  unsigned int detectedBoxes = m_Param.m_MaxDetections * m_Param.m_MaxClassesPerDetection;
83 
84  std::vector<TensorShape> results;
85  results.push_back({ 1, detectedBoxes, 4 });
86  results.push_back({ 1, detectedBoxes });
87  results.push_back({ 1, detectedBoxes });
88  results.push_back({ 1 });
89  return results;
90 }
91 
93 {
94  // For API stability DO NOT ALTER order and add new members to the end of vector
95  return { m_Anchors };
96 }
97 
99 {
100  ManagedConstTensorHandle managedAnchors(m_Anchors);
101  std::vector<armnn::ConstTensor> constTensors { {managedAnchors.GetTensorInfo(), managedAnchors.Map()} };
102  strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName());
103 }
104 
105 } // namespace armnn
-
DetectionPostProcessDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
-
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
-
- - - -
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the DetectionPostProcess type.
-
DetectionPostProcessLayer(const DetectionPostProcessDescriptor &param, const char *name)
Constructor to create a DetectionPostProcessLayer.
-
This layer represents a detection postprocess operator.
-
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition: Layer.cpp:491
-
const TensorInfo & GetTensorInfo() const
-
Copyright (c) 2021 ARM Limited and Contributors.
-
const DetectionPostProcessDescriptor & GetParameters() const override
- - -
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:206
-
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:322
-
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition: Layer.cpp:422
-
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
-
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
The model does not specify the output shapes.
- -
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:378
-
-
uint32_t m_MaxDetections
Maximum numbers of detections.
-
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:324
- -
void DetectionPostProcess(const TensorInfo &boxEncodingsInfo, const TensorInfo &scoresInfo, const TensorInfo &anchorsInfo, const TensorInfo &detectionBoxesInfo, const TensorInfo &detectionClassesInfo, const TensorInfo &detectionScoresInfo, const TensorInfo &numDetectionsInfo, const DetectionPostProcessDescriptor &desc, Decoder< float > &boxEncodings, Decoder< float > &scores, Decoder< float > &anchors, float *detectionBoxes, float *detectionClasses, float *detectionScores, float *numDetections)
-
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
Definition: INetwork.hpp:124
- -
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
-
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
-
ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
-
virtual void ExecuteStrategy(const IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
-
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
- -
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:274
-
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of DetectionPostProcessLayer.
- -
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
-
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:326
-
virtual const TensorInfo & GetTensorInfo() const =0
-
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:319
-
const ConstTensorHandle * m_Anchors
- -
DetectionPostProcessLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
-
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
-
-
std::shared_ptr< ConstTensorHandle > m_Anchors
A unique pointer to store Anchor values.
-
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
-
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:92
-
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:423
- -
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
-
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
-
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:466
+Go to the documentation of this file.
1 //
+
2 // Copyright © 2017-2023 Arm Ltd and Contributors. All rights reserved.
+
3 // SPDX-License-Identifier: MIT
+
4 //
+
5 
+ +
7 
+
8 #include "LayerCloneBase.hpp"
+
9 
+
10 #include <armnn/TypesUtils.hpp>
+ + + +
14 
+
15 namespace armnn
+
16 {
+
17 
+ + +
20 {
+
21 }
+
22 
+
23 std::unique_ptr<IWorkload> DetectionPostProcessLayer::CreateWorkload(const armnn::IWorkloadFactory& factory) const
+
24 {
+ +
26  descriptor.m_Anchors = m_Anchors.get();
+
27  SetAdditionalInfo(descriptor);
+
28 
+
29  return factory.CreateWorkload(LayerType::DetectionPostProcess, descriptor, PrepInfoAndDesc(descriptor));
+
30 }
+
31 
+ +
33 {
+
34  auto layer = CloneBase<DetectionPostProcessLayer>(graph, m_Param, GetName());
+
35  layer->m_Anchors = m_Anchors ? m_Anchors : nullptr;
+
36  return std::move(layer);
+
37 }
+
38 
+ +
40 {
+ +
42 
+
43  const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
+
44 
+ +
46 
+
47  // on this level constant data should not be released.
+
48  ARMNN_ASSERT_MSG(m_Anchors != nullptr, "DetectionPostProcessLayer: Anchors data should not be null.");
+
49 
+
50  ARMNN_ASSERT_MSG(GetNumOutputSlots() == 4, "DetectionPostProcessLayer: The layer should return 4 outputs.");
+
51 
+
52  std::vector<TensorShape> inferredShapes = InferOutputShapes(
+ + +
55 
+
56  ARMNN_ASSERT(inferredShapes.size() == 4);
+
57  ARMNN_ASSERT(inferredShapes[0].GetDimensionality() == Dimensionality::Specified);
+
58  ARMNN_ASSERT(inferredShapes[1].GetDimensionality() == Dimensionality::Specified);
+
59  ARMNN_ASSERT(inferredShapes[2].GetDimensionality() == Dimensionality::Specified);
+
60  ARMNN_ASSERT(inferredShapes[3].GetDimensionality() == Dimensionality::Specified);
+
61 
+
62  ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "DetectionPostProcessLayer");
+
63 
+ +
65  inferredShapes[1],
+ +
67  "DetectionPostProcessLayer", 1);
+
68 
+ +
70  inferredShapes[2],
+ +
72  "DetectionPostProcessLayer", 2);
+
73 
+ +
75  inferredShapes[3],
+ +
77  "DetectionPostProcessLayer", 3);
+
78 }
+
79 
+
80 std::vector<TensorShape> DetectionPostProcessLayer::InferOutputShapes(const std::vector<TensorShape>&) const
+
81 {
+
82  unsigned int detectedBoxes = m_Param.m_MaxDetections * m_Param.m_MaxClassesPerDetection;
+
83 
+
84  std::vector<TensorShape> results;
+
85  results.push_back({ 1, detectedBoxes, 4 });
+
86  results.push_back({ 1, detectedBoxes });
+
87  results.push_back({ 1, detectedBoxes });
+
88  results.push_back({ 1 });
+
89  return results;
+
90 }
+
91 
+ +
93 {
+
94  // For API stability DO NOT ALTER order and add new members to the end of vector
+
95  return { m_Anchors };
+
96 }
+
97 
+ +
99 {
+
100  ManagedConstTensorHandle managedAnchors(m_Anchors);
+
101  std::vector<armnn::ConstTensor> constTensors { {managedAnchors.GetTensorInfo(), managedAnchors.Map()} };
+
102  strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName());
+
103 }
+
104 
+
105 } // namespace armnn
+
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
+ +
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:322
+
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
+
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:378
+
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:206
+
+ +
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
+ +
uint32_t m_MaxDetections
Maximum numbers of detections.
+
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
+
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
Definition: INetwork.hpp:124
+
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition: Layer.cpp:491
+ + +
const ConstTensorHandle * m_Anchors
+ +
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:274
+
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:423
+
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition: Layer.cpp:422
+
const TensorInfo & GetTensorInfo() const
+
This layer represents a detection postprocess operator.
+
Copyright (c) 2021 ARM Limited and Contributors.
+ +
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the DetectionPostProcess type.
+
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:92
+
+ +
+
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition: Types.hpp:466
+
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
The model does not specify the output shapes.
+
std::shared_ptr< ConstTensorHandle > m_Anchors
A unique pointer to store Anchor values.
+
virtual const TensorInfo & GetTensorInfo() const =0
+
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:326
+
DetectionPostProcessLayer(const DetectionPostProcessDescriptor &param, const char *name)
Constructor to create a DetectionPostProcessLayer.
+
ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
+
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
+
void DetectionPostProcess(const TensorInfo &boxEncodingsInfo, const TensorInfo &scoresInfo, const TensorInfo &anchorsInfo, const TensorInfo &detectionBoxesInfo, const TensorInfo &detectionClassesInfo, const TensorInfo &detectionScoresInfo, const TensorInfo &numDetectionsInfo, const DetectionPostProcessDescriptor &desc, Decoder< float > &boxEncodings, Decoder< float > &scores, Decoder< float > &anchors, float *detectionBoxes, float *detectionClasses, float *detectionScores, float *numDetections)
+
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
+
DetectionPostProcessLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
+
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
+ +
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:324
+ +
virtual void ExecuteStrategy(const IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
+ +
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
+
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
+
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
+
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:319
+ + +
const DetectionPostProcessDescriptor & GetParameters() const override
+
DetectionPostProcessDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
+
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of DetectionPostProcessLayer.
-- cgit v1.2.1