ArmNN
 20.05
TensorShape Class Reference

#include <Tensor.hpp>

Public Member Functions

 TensorShape ()
 Empty (invalid) constructor. More...
 
 TensorShape (unsigned int numDimensions)
 
 TensorShape (unsigned int numDimensions, const unsigned int *dimensionSizes)
 
 TensorShape (std::initializer_list< unsigned int > dimensionSizeList)
 
 TensorShape (const TensorShape &other)
 
TensorShapeoperator= (const TensorShape &other)
 
unsigned int operator[] (unsigned int i) const
 
unsigned int & operator[] (unsigned int i)
 
bool operator== (const TensorShape &other) const
 
bool operator!= (const TensorShape &other) const
 
unsigned int GetNumDimensions () const
 
unsigned int GetNumElements () const
 

Detailed Description

Definition at line 20 of file Tensor.hpp.

Constructor & Destructor Documentation

◆ TensorShape() [1/5]

Empty (invalid) constructor.

Definition at line 24 of file Tensor.cpp.

25  : m_NumDimensions(0)
26 {
27 }

◆ TensorShape() [2/5]

TensorShape ( unsigned int  numDimensions)

Definition at line 29 of file Tensor.cpp.

References armnn::MaxNumOfTensorDimensions.

30  : m_NumDimensions(numDimensions)
31 {
32  if (numDimensions < 1)
33  {
34  throw InvalidArgumentException("Tensor numDimensions must be greater than 0");
35  }
36 
37  if (numDimensions > MaxNumOfTensorDimensions)
38  {
39  throw InvalidArgumentException("Tensor numDimensions must be less than or equal to MaxNumOfTensorDimensions");
40  }
41 
42  std::fill(m_Dimensions.begin(), m_Dimensions.begin() + m_NumDimensions, 0);
43 }
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18

◆ TensorShape() [3/5]

TensorShape ( unsigned int  numDimensions,
const unsigned int *  dimensionSizes 
)

Definition at line 45 of file Tensor.cpp.

References armnn::MaxNumOfTensorDimensions.

46  : m_NumDimensions(numDimensions)
47 {
48  if (numDimensions < 1)
49  {
50  throw InvalidArgumentException("Tensor numDimensions must be greater than 0");
51  }
52 
53  if (numDimensions > MaxNumOfTensorDimensions)
54  {
55  throw InvalidArgumentException("Tensor numDimensions must be less than or equal to MaxNumOfTensorDimensions");
56  }
57 
58  if (dimensionSizes == nullptr)
59  {
60  throw InvalidArgumentException("Tensor dimensionSizes must not be NULL");
61  }
62 
63  std::copy(dimensionSizes, dimensionSizes + numDimensions, m_Dimensions.begin());
64 }
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18

◆ TensorShape() [4/5]

TensorShape ( std::initializer_list< unsigned int >  dimensionSizeList)

Definition at line 66 of file Tensor.cpp.

67  : TensorShape(boost::numeric_cast<unsigned int>(dimensionSizeList.size()), dimensionSizeList.begin())
68 {
69 }
TensorShape()
Empty (invalid) constructor.
Definition: Tensor.cpp:24

◆ TensorShape() [5/5]

TensorShape ( const TensorShape other)

Definition at line 71 of file Tensor.cpp.

72  : m_NumDimensions(other.m_NumDimensions)
73 {
74  std::copy(other.m_Dimensions.cbegin(), other.m_Dimensions.cbegin() + other.m_NumDimensions, m_Dimensions.begin());
75 }

Member Function Documentation

◆ GetNumDimensions()

unsigned int GetNumDimensions ( ) const
inline

◆ GetNumElements()

unsigned int GetNumElements ( ) const

Definition at line 107 of file Tensor.cpp.

References CHECK_LOCATION.

Referenced by armnn::DepthToSpace(), armnnUtils::FindMinMax(), TensorShape::GetNumDimensions(), and armnn::TransposeConvolution2dImpl().

108 {
109  if (m_NumDimensions == 0)
110  {
111  return 0;
112  }
113 
114  unsigned int count = 1;
115  for (unsigned int i = 0; i < m_NumDimensions; i++)
116  {
117  count *= m_Dimensions[i];
118  }
119 
120  return count;
121 }

◆ operator!=()

bool operator!= ( const TensorShape other) const

Definition at line 102 of file Tensor.cpp.

103 {
104  return !(*this == other);
105 }

◆ operator=()

TensorShape & operator= ( const TensorShape other)

Definition at line 77 of file Tensor.cpp.

78 {
79  m_NumDimensions = other.m_NumDimensions;
80  std::copy(other.m_Dimensions.cbegin(), other.m_Dimensions.cbegin() + other.m_NumDimensions, m_Dimensions.begin());
81  return *this;
82 }

◆ operator==()

bool operator== ( const TensorShape other) const

Definition at line 96 of file Tensor.cpp.

Referenced by TensorInfo::HasMultipleQuantizationScales().

97 {
98  return ((m_NumDimensions == other.m_NumDimensions) &&
99  std::equal(m_Dimensions.cbegin(), m_Dimensions.cbegin() + m_NumDimensions, other.m_Dimensions.cbegin()));
100 }

◆ operator[]() [1/2]

unsigned int operator[] ( unsigned int  i) const

Definition at line 84 of file Tensor.cpp.

85 {
86  CheckDimensionIndex(i);
87  return m_Dimensions.at(i);
88 }

◆ operator[]() [2/2]

unsigned int & operator[] ( unsigned int  i)

Definition at line 90 of file Tensor.cpp.

91 {
92  CheckDimensionIndex(i);
93  return m_Dimensions.at(i);
94 }

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