Compute Library
 21.08
DetectionPostProcessLayerNode Class Referencefinal

DetectionPostProcess Layer node. More...

#include <DetectionPostProcessLayerNode.h>

Collaboration diagram for DetectionPostProcessLayerNode:
[legend]

Public Member Functions

 DetectionPostProcessLayerNode (DetectionPostProcessLayerInfo detection_info)
 Constructor. More...
 
DetectionPostProcessLayerInfo detection_post_process_info () const
 DetectionPostProcess metadata accessor. More...
 
NodeType type () const override
 Returns node's type. More...
 
bool forward_descriptors () override
 Forwards descriptor information to outputs if possible. More...
 
TensorDescriptor configure_output (size_t idx) const override
 Calculates output configuration. More...
 
void accept (INodeVisitor &v) override
 Accepts a node visitor. More...
 
- Public Member Functions inherited from INode
 INode ()
 Constructor. More...
 
virtual ~INode ()=default
 Destructor. More...
 
 INode (const INode &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INodeoperator= (const INode &)=delete
 Prevent instances of this class from being copy assigned (As this class contains pointers) More...
 
 INode (INode &&)=default
 Allow instances of this class to be moved. More...
 
INodeoperator= (INode &&)=default
 Allow instances of this class to be move assigned. More...
 
virtual Status validate () const
 Validate node. More...
 
std::string name () const
 Returns node's name. More...
 
NodeID id () const
 Returns node's ID. More...
 
const Graphgraph () const
 Returns node's Graph. More...
 
Graphgraph ()
 Returns node's Graph. More...
 
void set_graph (Graph *g)
 Sets the graph that this node is registered to. More...
 
void set_id (NodeID id)
 Sets the node id. More...
 
void set_common_node_parameters (NodeParams common_params)
 Sets common node parameters. More...
 
void set_requested_target (Target target)
 Sets target preference. More...
 
void set_assigned_target (Target target)
 Sets the final execution target. More...
 
void set_output_tensor (TensorID tid, size_t idx)
 Sets the output tensor of at a given index. More...
 
const std::vector< TensorID > & inputs () const
 Returns inputs of the node. More...
 
const std::vector< TensorID > & outputs () const
 Returns outputs of the node. More...
 
const std::vector< EdgeID > & input_edges () const
 Returns input edge set. More...
 
const std::set< EdgeID > & output_edges () const
 Returns output edge set. More...
 
TensorID input_id (size_t idx) const
 Returns the tensor ID of a given input of the node. More...
 
TensorID output_id (size_t idx) const
 Returns the tensor ID of a given output of the node. More...
 
Tensorinput (size_t idx) const
 Returns the tensor of a given input of the node. More...
 
Tensoroutput (size_t idx) const
 Returns the tensor of a given output of the node. More...
 
EdgeID input_edge_id (size_t idx) const
 Returns the edge ID of a given input of the node. More...
 
Edgeinput_edge (size_t idx) const
 Returns the edge of a given input of the node. More...
 
size_t num_inputs () const
 Returns number of inputs of the node. More...
 
size_t num_outputs () const
 Returns number of outputs of the node. More...
 
NodeParams common_node_params () const
 Returns common node parameters. More...
 
Target requested_target () const
 Returns requested target for this node. More...
 
Target assigned_target () const
 Returns assigned target for this node. More...
 

Detailed Description

DetectionPostProcess Layer node.

Definition at line 34 of file DetectionPostProcessLayerNode.h.

Constructor & Destructor Documentation

◆ DetectionPostProcessLayerNode()

Constructor.

Parameters
[in]detection_infoDetectionPostProcess Layer information

Definition at line 35 of file DetectionPostProcessLayerNode.cpp.

36  : _info(detection_info)
37 {
38  _input_edges.resize(3, EmptyEdgeID);
39  _outputs.resize(4, NullTensorID);
40 }
constexpr EdgeID EmptyEdgeID
Definition: Types.h:77
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:73

Member Function Documentation

◆ accept()

void accept ( INodeVisitor v)
overridevirtual

Accepts a node visitor.

Parameters
[in]vVisitor to accept

Implements INode.

Definition at line 99 of file DetectionPostProcessLayerNode.cpp.

References INodeVisitor::visit().

100 {
101  v.visit(*this);
102 }

◆ configure_output()

TensorDescriptor configure_output ( size_t  idx) const
overridevirtual

Calculates output configuration.

Parameters
[in]idxOutput index to configure
Returns
Output descriptor configuration

Implements INode.

Definition at line 63 of file DetectionPostProcessLayerNode.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, arm_compute::F32, DetectionPostProcessLayerInfo::max_classes_per_detection(), and DetectionPostProcessLayerInfo::max_detections().

Referenced by DetectionPostProcessLayerNode::forward_descriptors().

64 {
65  ARM_COMPUTE_UNUSED(idx);
66  ARM_COMPUTE_ERROR_ON(idx >= _outputs.size());
67 
68  TensorDescriptor output_desc;
69  const unsigned int num_detected_box = _info.max_detections() * _info.max_classes_per_detection();
70 
71  switch(idx)
72  {
73  case 0:
74  // Configure boxes output
75  output_desc.shape = TensorShape(kNumCoordBox, num_detected_box, kBatchSize);
76  break;
77  case 1:
78  case 2:
79  // Configure classes or scores output
80  output_desc.shape = TensorShape(num_detected_box, kBatchSize);
81  break;
82  case 3:
83  // Configure num_detection
84  output_desc.shape = TensorShape(1);
85  break;
86  default:
87  ARM_COMPUTE_ERROR("Unsupported output index");
88  }
89  output_desc.data_type = DataType::F32;
90 
91  return output_desc;
92 }
unsigned int max_detections() const
Get max detections.
Definition: Types.h:1062
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
unsigned int max_classes_per_detection() const
Get max_classes per detection.
Definition: Types.h:1067

◆ detection_post_process_info()

DetectionPostProcessLayerInfo detection_post_process_info ( ) const

DetectionPostProcess metadata accessor.

Returns
DetectionPostProcess Layer info

Definition at line 42 of file DetectionPostProcessLayerNode.cpp.

Referenced by arm_compute::graph::backends::detail::validate_detection_post_process_layer().

43 {
44  return _info;
45 }

◆ forward_descriptors()

bool forward_descriptors ( )
overridevirtual

Forwards descriptor information to outputs if possible.

Returns
True if descriptor information could be forwarded otherwise false

Implements INode.

Definition at line 47 of file DetectionPostProcessLayerNode.cpp.

References ARM_COMPUTE_ERROR_ON, DetectionPostProcessLayerNode::configure_output(), Tensor::desc(), arm_compute::test::validation::dst, INode::input_id(), arm_compute::graph::NullTensorID, INode::output(), and INode::output_id().

48 {
49  if((input_id(0) != NullTensorID) && (input_id(1) != NullTensorID) && (input_id(2) != NullTensorID) && (output_id(0) != NullTensorID) && (output_id(1) != NullTensorID)
50  && (output_id(2) != NullTensorID) && (output_id(3) != NullTensorID))
51  {
52  for(unsigned int i = 0; i < 4; ++i)
53  {
54  Tensor *dst = output(i);
55  ARM_COMPUTE_ERROR_ON(dst == nullptr);
56  dst->desc() = configure_output(i);
57  }
58  return true;
59  }
60  return false;
61 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Tensor * output(size_t idx) const
Returns the tensor of a given output of the node.
Definition: INode.cpp:158
TensorID input_id(size_t idx) const
Returns the tensor ID of a given input of the node.
Definition: INode.cpp:137
TensorDescriptor configure_output(size_t idx) const override
Calculates output configuration.
TensorID output_id(size_t idx) const
Returns the tensor ID of a given output of the node.
Definition: INode.cpp:144
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:73

◆ type()

NodeType type ( ) const
overridevirtual

Returns node's type.

Returns
Node's type

Implements INode.

Definition at line 94 of file DetectionPostProcessLayerNode.cpp.

References arm_compute::graph::DetectionPostProcessLayer.


The documentation for this class was generated from the following files: