ArmNN
 24.08
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 393 of file Descriptors.cpp.

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

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 420 of file Descriptors.cpp.

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

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(), StridedSliceLayer::InferOutputShapes(), StridedSliceDescriptor::operator==(), StringifyLayerParameters< StridedSliceDescriptor >::Serialize(), and armnn::StridedSlice().

◆ 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