ArmNN
 24.02
StridedSliceDescriptor Struct Reference

A StridedSliceDescriptor for the StridedSliceLayer. More...

#include <Descriptors.hpp>

Inheritance diagram for StridedSliceDescriptor:
[legend]
Collaboration diagram for StridedSliceDescriptor:
[legend]

Public Member Functions

 StridedSliceDescriptor (const std::vector< int > &begin, const std::vector< int > &end, const std::vector< int > &stride)
 
 StridedSliceDescriptor ()
 
bool operator== (const StridedSliceDescriptor &rhs) const
 
int GetStartForAxis (const TensorShape &inputShape, unsigned int axis) const
 
int GetStopForAxis (const TensorShape &inputShape, unsigned int axis, int startForAxis) const
 
- Public Member Functions inherited from BaseDescriptor
virtual bool IsNull () const
 
virtual ~BaseDescriptor ()=default
 

Public Attributes

std::vector< int > m_Begin
 Begin values for the input that will be sliced. More...
 
std::vector< int > m_End
 End values for the input that will be sliced. More...
 
std::vector< int > m_Stride
 Stride values for the input that will be sliced. More...
 
int32_t m_BeginMask
 Begin mask value. More...
 
int32_t m_EndMask
 End mask value. More...
 
int32_t m_ShrinkAxisMask
 Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1. More...
 
int32_t m_EllipsisMask
 Ellipsis mask value. More...
 
int32_t m_NewAxisMask
 New axis mask value. More...
 
DataLayout m_DataLayout
 The data layout to be used (NCHW, NHWC). More...
 

Detailed Description

A StridedSliceDescriptor for the StridedSliceLayer.

Definition at line 1303 of file Descriptors.hpp.

Constructor & Destructor Documentation

◆ StridedSliceDescriptor() [1/2]

StridedSliceDescriptor ( const std::vector< int > &  begin,
const std::vector< int > &  end,
const std::vector< int > &  stride 
)
inline

Definition at line 1305 of file Descriptors.hpp.

1308  : m_Begin(begin)
1309  , m_End(end)
1310  , m_Stride(stride)
1311  , m_BeginMask(0)
1312  , m_EndMask(0)
1313  , m_ShrinkAxisMask(0)
1314  , m_EllipsisMask(0)
1315  , m_NewAxisMask(0)
1317  {}

References armnn::NCHW.

◆ StridedSliceDescriptor() [2/2]

Definition at line 1319 of file Descriptors.hpp.

1320  : StridedSliceDescriptor({}, {}, {})
1321  {}

Member Function Documentation

◆ GetStartForAxis()

int GetStartForAxis ( const TensorShape inputShape,
unsigned int  axis 
) const

Definition at line 392 of file Descriptors.cpp.

394 {
395  int start = m_Begin[axis];
396 
397  if (m_BeginMask & (1 << axis))
398  {
399  if (m_Stride[axis] > 0)
400  {
401  start = std::numeric_limits<int>::min();
402  }
403  else
404  {
405  start = std::numeric_limits<int>::max();
406  }
407  }
408 
409  const int axisSize = armnn::numeric_cast<int>(inputShape[axis]);
410  if (start < 0)
411  {
412  start += (axisSize);
413  }
414 
415  return std::max(0, std::min(start, axisSize - 1));
416 
417 }

References StridedSliceDescriptor::m_Begin, StridedSliceDescriptor::m_BeginMask, and StridedSliceDescriptor::m_Stride.

Referenced by armnnUtils::CalculateStridedSliceOutputTensorInfo(), StridedSliceLayer::InferOutputShapes(), and armnn::StridedSlice().

◆ GetStopForAxis()

int GetStopForAxis ( const TensorShape inputShape,
unsigned int  axis,
int  startForAxis 
) const

Definition at line 419 of file Descriptors.cpp.

422 {
423 
424  if (m_ShrinkAxisMask & (1 << axis))
425  {
426  return startForAxis + 1;
427  }
428 
429  int stop = m_End[axis];
430 
431  if (m_EndMask & (1 << axis))
432  {
433  if (m_Stride[axis] > 0)
434  {
435  stop = std::numeric_limits<int>::max();
436  }
437  else
438  {
439  stop = std::numeric_limits<int>::min();
440  }
441  }
442 
443  const int axisSize = armnn::numeric_cast<int>(inputShape[axis]);
444  if (stop < 0)
445  {
446  stop += axisSize;
447  }
448 
449  return m_Stride[axis] > 0 ? std::max(0, std::min(stop, axisSize)) :
450  std::max(-1, std::min(stop, axisSize - 1));
451 
452 }

References StridedSliceDescriptor::m_End, StridedSliceDescriptor::m_EndMask, StridedSliceDescriptor::m_ShrinkAxisMask, and StridedSliceDescriptor::m_Stride.

Referenced by armnnUtils::CalculateStridedSliceOutputTensorInfo(), StridedSliceLayer::InferOutputShapes(), and armnn::StridedSlice().

◆ operator==()

bool operator== ( const StridedSliceDescriptor rhs) const
inline

Definition at line 1323 of file Descriptors.hpp.

1324  {
1325  return m_Begin == rhs.m_Begin &&
1326  m_End == rhs.m_End &&
1327  m_Stride == rhs.m_Stride &&
1328  m_BeginMask == rhs.m_BeginMask &&
1329  m_EndMask == rhs.m_EndMask &&
1330  m_ShrinkAxisMask == rhs.m_ShrinkAxisMask &&
1331  m_EllipsisMask == rhs.m_EllipsisMask &&
1332  m_NewAxisMask == rhs.m_NewAxisMask &&
1333  m_DataLayout == rhs.m_DataLayout;
1334  }

References StridedSliceDescriptor::m_Begin, StridedSliceDescriptor::m_BeginMask, StridedSliceDescriptor::m_DataLayout, StridedSliceDescriptor::m_EllipsisMask, StridedSliceDescriptor::m_End, StridedSliceDescriptor::m_EndMask, StridedSliceDescriptor::m_NewAxisMask, StridedSliceDescriptor::m_ShrinkAxisMask, and StridedSliceDescriptor::m_Stride.

Member Data Documentation

◆ m_Begin

◆ m_BeginMask

◆ m_DataLayout

DataLayout m_DataLayout

The data layout to be used (NCHW, NHWC).

Definition at line 1363 of file Descriptors.hpp.

Referenced by StridedSliceDescriptor::operator==(), and StringifyLayerParameters< StridedSliceDescriptor >::Serialize().

◆ m_EllipsisMask

◆ m_End

◆ m_EndMask

◆ m_NewAxisMask

int32_t m_NewAxisMask

New axis mask value.

If set, the begin, end and stride is disregarded and a new 1 dimension is inserted to this location of the output tensor.

Definition at line 1360 of file Descriptors.hpp.

Referenced by StridedSliceLayer::CreateWorkload(), StridedSliceDescriptor::operator==(), and StringifyLayerParameters< StridedSliceDescriptor >::Serialize().

◆ m_ShrinkAxisMask

◆ m_Stride


The documentation for this struct was generated from the following files:
armnn::StridedSliceDescriptor::m_Begin
std::vector< int > m_Begin
Begin values for the input that will be sliced.
Definition: Descriptors.hpp:1342
armnn::StridedSliceDescriptor::m_EllipsisMask
int32_t m_EllipsisMask
Ellipsis mask value.
Definition: Descriptors.hpp:1357
armnn::StridedSliceDescriptor::m_BeginMask
int32_t m_BeginMask
Begin mask value.
Definition: Descriptors.hpp:1350
armnn::StridedSliceDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:1363
armnn::StridedSliceDescriptor::StridedSliceDescriptor
StridedSliceDescriptor()
Definition: Descriptors.hpp:1319
armnn::StridedSliceDescriptor::m_EndMask
int32_t m_EndMask
End mask value.
Definition: Descriptors.hpp:1353
armnn::StridedSliceDescriptor::m_ShrinkAxisMask
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1.
Definition: Descriptors.hpp:1355
armnn::StridedSliceDescriptor::m_Stride
std::vector< int > m_Stride
Stride values for the input that will be sliced.
Definition: Descriptors.hpp:1346
std
Definition: BackendId.hpp:149
armnn::StridedSliceDescriptor::m_End
std::vector< int > m_End
End values for the input that will be sliced.
Definition: Descriptors.hpp:1344
armnn::StridedSliceDescriptor::m_NewAxisMask
int32_t m_NewAxisMask
New axis mask value.
Definition: Descriptors.hpp:1360
armnn::DataLayout::NCHW
@ NCHW