ArmNN
 20.02
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 1002 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 1004 of file Descriptors.hpp.

1007  : m_Begin(begin)
1008  , m_End(end)
1009  , m_Stride(stride)
1010  , m_BeginMask(0)
1011  , m_EndMask(0)
1012  , m_ShrinkAxisMask(0)
1013  , m_EllipsisMask(0)
1014  , m_NewAxisMask(0)
1016  {}
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 1018 of file Descriptors.hpp.

1019  : StridedSliceDescriptor({}, {}, {})
1020  {}

Member Function Documentation

◆ GetStartForAxis()

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

Definition at line 358 of file Descriptors.cpp.

References armnn::numeric_cast().

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

360 {
361  int start = m_Begin[axis];
362 
363  if (m_BeginMask & (1 << axis))
364  {
365  if (m_Stride[axis] > 0)
366  {
367  start = std::numeric_limits<int>::min();
368  }
369  else
370  {
371  start = std::numeric_limits<int>::max();
372  }
373  }
374 
375  const int axisSize = boost::numeric_cast<int>(inputShape[axis]);
376  if (start < 0)
377  {
378  start += (axisSize);
379  }
380 
381  return std::max(0, std::min(start, axisSize - 1));
382 
383 }
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 385 of file Descriptors.cpp.

References armnn::numeric_cast().

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

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

1023  {
1024  return m_Begin == rhs.m_Begin &&
1025  m_End == rhs.m_End &&
1026  m_Stride == rhs.m_Stride &&
1027  m_BeginMask == rhs.m_BeginMask &&
1028  m_EndMask == rhs.m_EndMask &&
1029  m_ShrinkAxisMask == rhs.m_ShrinkAxisMask &&
1030  m_EllipsisMask == rhs.m_EllipsisMask &&
1031  m_NewAxisMask == rhs.m_NewAxisMask &&
1032  m_DataLayout == rhs.m_DataLayout;
1033  }
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 1059 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: