Compute Library
 22.11
PadLayerNode Class Referencefinal

Pad Layer node. More...

#include <PadLayerNode.h>

Collaboration diagram for PadLayerNode:
[legend]

Public Member Functions

 PadLayerNode (const PaddingList &padding, PixelValue pad_value=PixelValue())
 Constructor. More...
 
const PaddingListpadding () const
 Padding list accessor. More...
 
PixelValue pad_value () const
 Padding value 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...
 
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 Attributes

static constexpr NodeType node_type = NodeType::PadLayer
 

Detailed Description

Pad Layer node.

Definition at line 34 of file PadLayerNode.h.

Constructor & Destructor Documentation

◆ PadLayerNode()

PadLayerNode ( const PaddingList padding,
PixelValue  pad_value = PixelValue() 
)

Constructor.

Parameters
[in]paddingThe padding for each spatial dimension of the input tensor. The pair padding[i] specifies the front and the end padding in the i-th dimension.
[in]pad_valuePadding value to be used. Defaults to 0

Definition at line 35 of file PadLayerNode.cpp.

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

36  : _padding(padding), _pad_value(pad_value)
37 {
38  _input_edges.resize(1, EmptyEdgeID);
39  _outputs.resize(1, NullTensorID);
40 }
PixelValue pad_value() const
Padding value accessor.
const PaddingList & padding() const
Padding list accessor.
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 87 of file PadLayerNode.cpp.

References INodeVisitor::visit().

88 {
89  v.visit(*this);
90 }

◆ 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 64 of file PadLayerNode.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, INode::input(), arm_compute::test::validation::input_shape, TensorShape::set(), TensorDescriptor::shape, and arm_compute::test::validation::src.

Referenced by PadLayerNode::forward_descriptors().

65 {
66  ARM_COMPUTE_UNUSED(idx);
67  ARM_COMPUTE_ERROR_ON(idx >= _outputs.size());
68 
69  const Tensor *src = input(0);
70  ARM_COMPUTE_ERROR_ON(src == nullptr);
71 
72  TensorDescriptor output_desc = src->desc();
73  const TensorShape input_shape = src->desc().shape;
74  for(size_t dim = 0; dim < _padding.size(); ++dim)
75  {
76  output_desc.shape.set(dim, _padding[dim].first + input_shape[dim] + _padding[dim].second);
77  }
78 
79  return output_desc;
80 }
#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
const auto input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
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 52 of file PadLayerNode.cpp.

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

53 {
54  if((input_id(0) != NullTensorID) && (output_id(0) != NullTensorID))
55  {
56  Tensor *dst = output(0);
57  ARM_COMPUTE_ERROR_ON(dst == nullptr);
58  dst->desc() = configure_output(0);
59  return true;
60  }
61  return false;
62 }
#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:159
TensorID input_id(size_t idx) const
Returns the tensor ID of a given input of the node.
Definition: INode.cpp:138
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:145
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:74

◆ pad_value()

PixelValue pad_value ( ) const

Padding value accessor.

Returns
Padding value

Definition at line 47 of file PadLayerNode.cpp.

48 {
49  return _pad_value;
50 }

◆ padding()

const PaddingList & padding ( ) const

Padding list accessor.

Returns
Padding list

Definition at line 42 of file PadLayerNode.cpp.

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

43 {
44  return _padding;
45 }

◆ type()

NodeType type ( ) const
overridevirtual

Returns node's type.

Returns
Node's type

Implements INode.

Definition at line 82 of file PadLayerNode.cpp.

References arm_compute::graph::PadLayer.

Field Documentation

◆ node_type

constexpr NodeType node_type = NodeType::PadLayer
static

Definition at line 62 of file PadLayerNode.h.


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