ArmNN
 20.05
StridedSliceDescriptor Struct Reference

A StridedSliceDescriptor for the StridedSliceLayer. More...

#include <Descriptors.hpp>

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 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 1014 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 1016 of file Descriptors.hpp.

1019  : m_Begin(begin)
1020  , m_End(end)
1021  , m_Stride(stride)
1022  , m_BeginMask(0)
1023  , m_EndMask(0)
1024  , m_ShrinkAxisMask(0)
1025  , m_EllipsisMask(0)
1026  , m_NewAxisMask(0)
1028  {}
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 1030 of file Descriptors.hpp.

1031  : StridedSliceDescriptor({}, {}, {})
1032  {}

Member Function Documentation

◆ GetStartForAxis()

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

Definition at line 360 of file Descriptors.cpp.

References armnn::numeric_cast().

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

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

◆ GetStopForAxis()

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

Definition at line 387 of file Descriptors.cpp.

References armnn::numeric_cast().

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

390 {
391 
392  if (m_ShrinkAxisMask & (1 << axis))
393  {
394  return startForAxis + 1;
395  }
396 
397  int stop = m_End[axis];
398 
399  if (m_EndMask & (1 << axis))
400  {
401  if (m_Stride[axis] > 0)
402  {
403  stop = std::numeric_limits<int>::max();
404  }
405  else
406  {
407  stop = std::numeric_limits<int>::min();
408  }
409  }
410 
411  const int axisSize = boost::numeric_cast<int>(inputShape[axis]);
412  if (stop < 0)
413  {
414  stop += axisSize;
415  }
416 
417  return m_Stride[axis] > 0 ? std::max(0, std::min(stop, axisSize)) :
418  std::max(-1, std::min(stop, axisSize - 1));
419 
420 }
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::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
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.

◆ operator==()

bool operator== ( const StridedSliceDescriptor rhs) const
inline

Definition at line 1034 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.

1035  {
1036  return m_Begin == rhs.m_Begin &&
1037  m_End == rhs.m_End &&
1038  m_Stride == rhs.m_Stride &&
1039  m_BeginMask == rhs.m_BeginMask &&
1040  m_EndMask == rhs.m_EndMask &&
1041  m_ShrinkAxisMask == rhs.m_ShrinkAxisMask &&
1042  m_EllipsisMask == rhs.m_EllipsisMask &&
1043  m_NewAxisMask == rhs.m_NewAxisMask &&
1044  m_DataLayout == rhs.m_DataLayout;
1045  }
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 1071 of file Descriptors.hpp.

Referenced by StridedSliceLayer::CreateWorkload(), StridedSliceDescriptor::operator==(), TfLiteParser::OutputShapeOfSqueeze(), armnnTfParser::OutputShapeOfSqueeze(), StringifyLayerParameters< StridedSliceDescriptor >::Serialize(), and SerializerVisitor::VisitStridedSliceLayer().

◆ m_ShrinkAxisMask

◆ m_Stride


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