ArmNN
 22.11
StridedSliceDescriptor Struct Reference

A StridedSliceDescriptor for the StridedSliceLayer. More...

#include <Descriptors.hpp>

Inheritance diagram for StridedSliceDescriptor:
BaseDescriptor

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 1243 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 1245 of file Descriptors.hpp.

1248  : m_Begin(begin)
1249  , m_End(end)
1250  , m_Stride(stride)
1251  , m_BeginMask(0)
1252  , m_EndMask(0)
1253  , m_ShrinkAxisMask(0)
1254  , m_EllipsisMask(0)
1255  , m_NewAxisMask(0)
1257  {}
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1...
std::vector< int > m_Begin
Begin values for the input that will be sliced.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
int32_t m_BeginMask
Begin mask value.
int32_t m_EndMask
End mask value.
int32_t m_NewAxisMask
New axis mask value.
int32_t m_EllipsisMask
Ellipsis mask value.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
std::vector< int > m_End
End values for the input that will be sliced.

◆ StridedSliceDescriptor() [2/2]

Definition at line 1259 of file Descriptors.hpp.

1260  : StridedSliceDescriptor({}, {}, {})
1261  {}

Member Function Documentation

◆ GetStartForAxis()

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

Definition at line 366 of file Descriptors.cpp.

References armnn::numeric_cast().

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

368 {
369  int start = m_Begin[axis];
370 
371  if (m_BeginMask & (1 << axis))
372  {
373  if (m_Stride[axis] > 0)
374  {
375  start = std::numeric_limits<int>::min();
376  }
377  else
378  {
379  start = std::numeric_limits<int>::max();
380  }
381  }
382 
383  const int axisSize = armnn::numeric_cast<int>(inputShape[axis]);
384  if (start < 0)
385  {
386  start += (axisSize);
387  }
388 
389  return std::max(0, std::min(start, axisSize - 1));
390 
391 }
std::vector< int > m_Begin
Begin values for the input that will be sliced.
int32_t m_BeginMask
Begin mask value.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ GetStopForAxis()

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

Definition at line 393 of file Descriptors.cpp.

References armnn::numeric_cast().

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

396 {
397 
398  if (m_ShrinkAxisMask & (1 << axis))
399  {
400  return startForAxis + 1;
401  }
402 
403  int stop = m_End[axis];
404 
405  if (m_EndMask & (1 << axis))
406  {
407  if (m_Stride[axis] > 0)
408  {
409  stop = std::numeric_limits<int>::max();
410  }
411  else
412  {
413  stop = std::numeric_limits<int>::min();
414  }
415  }
416 
417  const int axisSize = armnn::numeric_cast<int>(inputShape[axis]);
418  if (stop < 0)
419  {
420  stop += axisSize;
421  }
422 
423  return m_Stride[axis] > 0 ? std::max(0, std::min(stop, axisSize)) :
424  std::max(-1, std::min(stop, axisSize - 1));
425 
426 }
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1...
int32_t m_EndMask
End mask value.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
std::vector< int > m_End
End values for the input that will be sliced.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ operator==()

bool operator== ( const StridedSliceDescriptor rhs) const
inline

Definition at line 1263 of file Descriptors.hpp.

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.

1264  {
1265  return m_Begin == rhs.m_Begin &&
1266  m_End == rhs.m_End &&
1267  m_Stride == rhs.m_Stride &&
1268  m_BeginMask == rhs.m_BeginMask &&
1269  m_EndMask == rhs.m_EndMask &&
1270  m_ShrinkAxisMask == rhs.m_ShrinkAxisMask &&
1271  m_EllipsisMask == rhs.m_EllipsisMask &&
1272  m_NewAxisMask == rhs.m_NewAxisMask &&
1273  m_DataLayout == rhs.m_DataLayout;
1274  }
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1...
std::vector< int > m_Begin
Begin values for the input that will be sliced.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
int32_t m_BeginMask
Begin mask value.
int32_t m_EndMask
End mask value.
int32_t m_NewAxisMask
New axis mask value.
int32_t m_EllipsisMask
Ellipsis mask value.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
std::vector< int > m_End
End values for the input that will be sliced.

Member Data Documentation

◆ m_Begin

◆ m_BeginMask

◆ m_DataLayout

◆ 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 1300 of file Descriptors.hpp.

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

◆ m_ShrinkAxisMask

◆ m_Stride


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