Compute Library
 21.02
StridedSliceLayerNode Class Referencefinal

Slice Layer node. More...

#include <StridedSliceLayerNode.h>

Collaboration diagram for StridedSliceLayerNode:
[legend]

Public Member Functions

 StridedSliceLayerNode (const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, StridedSliceLayerInfo strided_slice_info)
 Default Constructor. More...
 
Coordinates starts () const
 Start coordinates accessor. More...
 
Coordinates ends () const
 End coordinates accessor. More...
 
BiStrides strides () const
 Strides vector accessor. More...
 
StridedSliceLayerInfo strided_slice_info () const
 
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 Member Functions

static TensorDescriptor compute_output_descriptor (const TensorDescriptor &input_descriptor, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, StridedSliceLayerInfo info)
 Computes slice layer output descriptor. More...
 

Detailed Description

Slice Layer node.

Definition at line 36 of file StridedSliceLayerNode.h.

Constructor & Destructor Documentation

◆ StridedSliceLayerNode()

StridedSliceLayerNode ( const Coordinates starts,
const Coordinates ends,
const BiStrides strides,
StridedSliceLayerInfo  strided_slice_info 
)

Default Constructor.

Parameters
[in]startsThe starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]endsThe ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]stridesThe strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]strided_slice_infoContains masks for the starts, ends and strides

Definition at line 35 of file StridedSliceLayerNode.cpp.

39  : _starts(starts), _ends(ends), _strides(strides), _info(std::move(info))
40 {
41  _input_edges.resize(1, EmptyEdgeID);
42  _outputs.resize(1, NullTensorID);
43 }
Coordinates ends() const
End coordinates accessor.
BiStrides strides() const
Strides vector accessor.
constexpr EdgeID EmptyEdgeID
Definition: Types.h:75
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:71
Coordinates starts() const
Start coordinates accessor.

Member Function Documentation

◆ accept()

void accept ( INodeVisitor v)
overridevirtual

Accepts a node visitor.

Parameters
[in]vVisitor to accept

Implements INode.

Definition at line 108 of file StridedSliceLayerNode.cpp.

References INodeVisitor::visit().

109 {
110  v.visit(*this);
111 }

◆ compute_output_descriptor()

TensorDescriptor compute_output_descriptor ( const TensorDescriptor input_descriptor,
const Coordinates starts,
const Coordinates ends,
const BiStrides strides,
StridedSliceLayerInfo  info 
)
static

Computes slice layer output descriptor.

Parameters
[in]input_descriptorDescriptor of the input tensor
[in]startsThe starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]endsThe ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]stridesThe strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]infoContains masks for the starts, ends and strides
Returns
Output descriptor

Definition at line 65 of file StridedSliceLayerNode.cpp.

References StridedSliceLayerInfo::begin_mask(), arm_compute::helpers::tensor_transform::compute_strided_slice_output_shape(), StridedSliceLayerInfo::end_mask(), TensorDescriptor::shape, and StridedSliceLayerInfo::shrink_axis_mask().

Referenced by StridedSliceLayerNode::configure_output().

70 {
72 
73  TensorDescriptor output_desc = input_descriptor;
74  output_desc.shape = compute_strided_slice_output_shape(input_descriptor.shape, starts, ends, strides,
75  info.begin_mask(), info.end_mask(), info.shrink_axis_mask());
76 
77  return output_desc;
78 }
Coordinates ends() const
End coordinates accessor.
BiStrides strides() const
Strides vector accessor.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Coordinates starts() const
Start coordinates accessor.
TensorShape compute_strided_slice_output_shape(TensorShape input_shape, Coordinates starts, Coordinates ends, Coordinates strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0, bool return_unshrinked=false)
Computes output shape of strided slice.

◆ 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 92 of file StridedSliceLayerNode.cpp.

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

Referenced by StridedSliceLayerNode::forward_descriptors().

93 {
94  ARM_COMPUTE_UNUSED(idx);
95  ARM_COMPUTE_ERROR_ON(idx >= _outputs.size());
96 
97  const Tensor *src = input(0);
98  ARM_COMPUTE_ERROR_ON(src == nullptr);
99 
100  return compute_output_descriptor(src->desc(), _starts, _ends, _strides, _info);
101 }
static TensorDescriptor compute_output_descriptor(const TensorDescriptor &input_descriptor, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, StridedSliceLayerInfo info)
Computes slice layer output descriptor.
#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
Tensor * input(size_t idx) const
Returns the tensor of a given input of the node.
Definition: INode.cpp:150

◆ ends()

Coordinates ends ( ) const

End coordinates accessor.

Returns
End coordinates of the dimensions

Definition at line 50 of file StridedSliceLayerNode.cpp.

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

51 {
52  return _ends;
53 }

◆ 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 80 of file StridedSliceLayerNode.cpp.

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

81 {
82  if((input_id(0) != NullTensorID) && (output_id(0) != NullTensorID))
83  {
84  Tensor *dst = output(0);
85  ARM_COMPUTE_ERROR_ON(dst == nullptr);
86  dst->desc() = configure_output(0);
87  return true;
88  }
89  return false;
90 }
#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:158
TensorID input_id(size_t idx) const
Returns the tensor ID of a given input of the node.
Definition: INode.cpp:137
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:71

◆ starts()

Coordinates starts ( ) const

Start coordinates accessor.

Returns
Start coordinates of the dimensions

Definition at line 45 of file StridedSliceLayerNode.cpp.

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

46 {
47  return _starts;
48 }

◆ strided_slice_info()

StridedSliceLayerInfo strided_slice_info ( ) const

Definition at line 60 of file StridedSliceLayerNode.cpp.

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

61 {
62  return _info;
63 }

◆ strides()

BiStrides strides ( ) const

Strides vector accessor.

Returns
End coordinates of the dimensions

Definition at line 55 of file StridedSliceLayerNode.cpp.

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

56 {
57  return _strides;
58 }

◆ type()

NodeType type ( ) const
overridevirtual

Returns node's type.

Returns
Node's type

Implements INode.

Definition at line 103 of file StridedSliceLayerNode.cpp.

References arm_compute::graph::StridedSliceLayer.


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