Compute Library
 21.08
ArgMinMaxLayerNode Class Referencefinal

Arg Min/Max Layer node. More...

#include <ArgMinMaxLayerNode.h>

Collaboration diagram for ArgMinMaxLayerNode:
[legend]

Public Member Functions

 ArgMinMaxLayerNode (ReductionOperation op, unsigned int axis, DataType out_data_type=DataType::UNKNOWN, QuantizationInfo out_quant_info=QuantizationInfo())
 Constructor. More...
 
ReductionOperation reduction_operation () const
 Operator accessor. More...
 
unsigned int axis () const
 Axis accessor. More...
 
DataType out_data_type () const
 Output data type 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...
 

Static Public Attributes

static constexpr NodeType node_type = NodeType::ArgMinMaxLayer
 

Detailed Description

Arg Min/Max Layer node.

Definition at line 34 of file ArgMinMaxLayerNode.h.

Constructor & Destructor Documentation

◆ ArgMinMaxLayerNode()

ArgMinMaxLayerNode ( ReductionOperation  op,
unsigned int  axis,
DataType  out_data_type = DataType::UNKNOWN,
QuantizationInfo  out_quant_info = QuantizationInfo() 
)

Constructor.

Parameters
[in]opOperation to perform: min or max
[in]axisAxis along which to reduce. Supported reduction axis : 0,1,2,3
[in]out_data_type(Optional) Output data type
[in]out_quant_info(Optional) Output quantization info

Definition at line 35 of file ArgMinMaxLayerNode.cpp.

References arm_compute::graph::EmptyEdgeID, and arm_compute::graph::NullTensorID.

36  : _op(op), _axis(axis), _out_data_type(out_data_type), _out_quant_info(std::move(out_quant_info))
37 {
38  _input_edges.resize(1, EmptyEdgeID);
39  _outputs.resize(1, NullTensorID);
40 }
DataType out_data_type() const
Output data type accessor.
constexpr EdgeID EmptyEdgeID
Definition: Types.h:77
unsigned int axis() const
Axis accessor.
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 ArgMinMaxLayerNode.cpp.

References INodeVisitor::visit().

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

◆ axis()

unsigned int axis ( ) const

Axis accessor.

Returns
The axis along which the reduction is operating

Definition at line 47 of file ArgMinMaxLayerNode.cpp.

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

48 {
49  return _axis;
50 }

◆ 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 69 of file ArgMinMaxLayerNode.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, arm_compute::misc::shape_calculator::compute_reduced_shape(), TensorDescriptor::data_type, QuantizationInfo::empty(), INode::input(), arm_compute::test::validation::output_info, arm_compute::test::validation::output_shape, TensorDescriptor::quant_info, TensorDescriptor::set_shape(), TensorDescriptor::shape, arm_compute::test::validation::src, and arm_compute::UNKNOWN.

Referenced by ArgMinMaxLayerNode::forward_descriptors().

70 {
71  ARM_COMPUTE_UNUSED(idx);
72  ARM_COMPUTE_ERROR_ON(idx >= _outputs.size());
73 
74  const Tensor *src = input(0);
75  ARM_COMPUTE_ERROR_ON(src == nullptr);
76 
77  TensorDescriptor output_info = src->desc();
78  if(!_out_quant_info.empty())
79  {
80  output_info.quant_info = _out_quant_info;
81  }
82 
83  if(_out_data_type != DataType::UNKNOWN)
84  {
85  output_info.data_type = _out_data_type;
86  }
87 
88  TensorShape output_shape = arm_compute::misc::shape_calculator::compute_reduced_shape(output_info.shape, _axis, false);
89  output_info.set_shape(output_shape);
90 
91  return output_info;
92 }
#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
SimpleTensor< float > src
Definition: DFT.cpp:155
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
TensorShape compute_reduced_shape(const TensorShape &input, unsigned int axis, bool keep_dims=true)
Calculate the reduced shape of a tensor given an axis.
bool empty() const
Indicates whether this QuantizationInfo has valid settings or not.
Tensor * input(size_t idx) const
Returns the tensor of a given input of the node.
Definition: INode.cpp:150

◆ 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 57 of file ArgMinMaxLayerNode.cpp.

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

58 {
59  if((input_id(0) != NullTensorID) && (output_id(0) != NullTensorID))
60  {
61  Tensor *dst = output(0);
62  ARM_COMPUTE_ERROR_ON(dst == nullptr);
63  dst->desc() = configure_output(0);
64  return true;
65  }
66  return false;
67 }
#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

◆ out_data_type()

DataType out_data_type ( ) const

Output data type accessor.

Returns
The output data type

Definition at line 52 of file ArgMinMaxLayerNode.cpp.

53 {
54  return _out_data_type;
55 }

◆ reduction_operation()

ReductionOperation reduction_operation ( ) const

Operator accessor.

Returns
The operator the layer performs: min or max

Definition at line 42 of file ArgMinMaxLayerNode.cpp.

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

43 {
44  return _op;
45 }

◆ type()

NodeType type ( ) const
overridevirtual

Returns node's type.

Returns
Node's type

Implements INode.

Definition at line 94 of file ArgMinMaxLayerNode.cpp.

References ArgMinMaxLayerNode::node_type.

95 {
97 }

Field Documentation

◆ node_type

constexpr NodeType node_type = NodeType::ArgMinMaxLayer
static

Definition at line 71 of file ArgMinMaxLayerNode.h.

Referenced by ArgMinMaxLayerNode::type().


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