Compute Library
 22.11
ReorgLayerNode Class Referencefinal

Reorg Layer node. More...

#include <ReorgLayerNode.h>

Collaboration diagram for ReorgLayerNode:
[legend]

Public Member Functions

 ReorgLayerNode (int stride)
 Constructor. More...
 
int stride () const
 Stride value to use for reorganizing the values in the output tensor. 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...
 
const std::list< std::unique_ptr< ConvPostOpInfo > > & post_op_info_list () const
 Post operator info list. More...
 
std::list< std::unique_ptr< ConvPostOpInfo > > & post_op_info_list ()
 Post operator info list. More...
 

Static Public Member Functions

static TensorDescriptor compute_output_descriptor (const TensorDescriptor &input_descriptor, int stride)
 Computes reorg output descriptor. More...
 

Detailed Description

Reorg Layer node.

Definition at line 34 of file ReorgLayerNode.h.

Constructor & Destructor Documentation

◆ ReorgLayerNode()

ReorgLayerNode ( int  stride)

Constructor.

Parameters
[in]strideStride value to use for reorganizing the values in the output tensor.

Definition at line 34 of file ReorgLayerNode.cpp.

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

35  : _stride(stride)
36 {
37  _input_edges.resize(1, EmptyEdgeID);
38  _outputs.resize(1, NullTensorID);
39 }
int stride() const
Stride value to use for reorganizing the values in the output tensor.
constexpr EdgeID EmptyEdgeID
Definition: Types.h:78
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:74

Member Function Documentation

◆ accept()

void accept ( INodeVisitor v)
overridevirtual

Accepts a node visitor.

Parameters
[in]vVisitor to accept

Implements INode.

Definition at line 93 of file ReorgLayerNode.cpp.

References INodeVisitor::visit().

94 {
95  v.visit(*this);
96 }

◆ compute_output_descriptor()

TensorDescriptor compute_output_descriptor ( const TensorDescriptor input_descriptor,
int  stride 
)
static

Computes reorg output descriptor.

Parameters
[in]input_descriptorInput descriptor
[in]strideStride value to use for reorganizing the values in the output tensor.
Returns
Output descriptor

Definition at line 46 of file ReorgLayerNode.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_MSG, arm_compute::CHANNEL, arm_compute::test::validation::data_layout, arm_compute::graph::get_dimension_idx(), arm_compute::graph::get_dimension_size(), arm_compute::HEIGHT, input_height, input_width, TensorDescriptor::layout, TensorShape::set(), TensorDescriptor::shape, and arm_compute::WIDTH.

Referenced by ReorgLayerNode::configure_output().

47 {
48  const unsigned int input_width = get_dimension_size(input_descriptor, DataLayoutDimension::WIDTH);
49  const unsigned int input_height = get_dimension_size(input_descriptor, DataLayoutDimension::HEIGHT);
50  const unsigned int input_channel = get_dimension_size(input_descriptor, DataLayoutDimension::CHANNEL);
51 
53  ARM_COMPUTE_ERROR_ON_MSG((input_width % stride != 0), "The width of the input tensor must be a multiple of stride");
54  ARM_COMPUTE_ERROR_ON_MSG((input_height % stride != 0), "The height of the input tensor must be a multiple of stride");
55 
56  const DataLayout data_layout = input_descriptor.layout;
57  TensorDescriptor output_descriptor = input_descriptor;
58  output_descriptor.shape.set(get_dimension_idx(data_layout, DataLayoutDimension::WIDTH), input_width / stride);
59  output_descriptor.shape.set(get_dimension_idx(data_layout, DataLayoutDimension::HEIGHT), input_height / stride);
60  output_descriptor.shape.set(get_dimension_idx(data_layout, DataLayoutDimension::CHANNEL), input_channel * stride * stride);
61 
62  return output_descriptor;
63 }
int stride() const
Stride value to use for reorganizing the values in the output tensor.
size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
Get size of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:142
#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
const size_t input_height
Definition: impl.cpp:61
const size_t input_width
Definition: impl.cpp:62
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:148

◆ 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 77 of file ReorgLayerNode.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, ReorgLayerNode::compute_output_descriptor(), INode::input(), and arm_compute::test::validation::src.

Referenced by ReorgLayerNode::forward_descriptors().

78 {
79  ARM_COMPUTE_UNUSED(idx);
80  ARM_COMPUTE_ERROR_ON(idx >= _outputs.size());
81 
82  const Tensor *src = input(0);
83  ARM_COMPUTE_ERROR_ON(src == nullptr);
84 
85  return compute_output_descriptor(src->desc(), _stride);
86 }
#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
static TensorDescriptor compute_output_descriptor(const TensorDescriptor &input_descriptor, int stride)
Computes reorg output descriptor.
Tensor * input(size_t idx) const
Returns the tensor of a given input of the node.
Definition: INode.cpp:151

◆ 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 65 of file ReorgLayerNode.cpp.

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

66 {
67  if((input_id(0) != NullTensorID) && (output_id(0) != NullTensorID))
68  {
69  Tensor *dst = output(0);
70  ARM_COMPUTE_ERROR_ON(dst == nullptr);
71  dst->desc() = configure_output(0);
72  return true;
73  }
74  return false;
75 }
#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
TensorDescriptor configure_output(size_t idx) const override
Calculates output configuration.
Tensor * output(size_t idx) const
Returns the tensor of a given output of the node.
Definition: INode.cpp:159
TensorID input_id(size_t idx) const
Returns the tensor ID of a given input of the node.
Definition: INode.cpp:138
TensorID output_id(size_t idx) const
Returns the tensor ID of a given output of the node.
Definition: INode.cpp:145
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:74

◆ stride()

int stride ( ) const

Stride value to use for reorganizing the values in the output tensor.

Returns
Stride value to use for reorganizing the values in the output tensor.

Definition at line 41 of file ReorgLayerNode.cpp.

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

42 {
43  return _stride;
44 }

◆ type()

NodeType type ( ) const
overridevirtual

Returns node's type.

Returns
Node's type

Implements INode.

Definition at line 88 of file ReorgLayerNode.cpp.

References arm_compute::graph::ReorgLayer.


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