ArmNN
 20.02
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 23 of file Tensor.cpp.

24  : m_NumDimensions(0)
25 {
26 }

◆ TensorShape() [2/5]

TensorShape ( unsigned int  numDimensions)

Definition at line 28 of file Tensor.cpp.

References armnn::MaxNumOfTensorDimensions.

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

◆ TensorShape() [3/5]

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

Definition at line 44 of file Tensor.cpp.

References armnn::MaxNumOfTensorDimensions.

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

◆ TensorShape() [4/5]

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

Definition at line 65 of file Tensor.cpp.

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

◆ TensorShape() [5/5]

TensorShape ( const TensorShape other)

Definition at line 70 of file Tensor.cpp.

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

Member Function Documentation

◆ GetNumDimensions()

unsigned int GetNumDimensions ( ) const
inline

◆ GetNumElements()

unsigned int GetNumElements ( ) const

Definition at line 106 of file Tensor.cpp.

References CHECK_LOCATION.

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

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

◆ operator!=()

bool operator!= ( const TensorShape other) const

Definition at line 101 of file Tensor.cpp.

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

◆ operator=()

TensorShape & operator= ( const TensorShape other)

Definition at line 76 of file Tensor.cpp.

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

◆ operator==()

bool operator== ( const TensorShape other) const

Definition at line 95 of file Tensor.cpp.

Referenced by TensorInfo::HasMultipleQuantizationScales().

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

◆ operator[]() [1/2]

unsigned int operator[] ( unsigned int  i) const

Definition at line 83 of file Tensor.cpp.

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

◆ operator[]() [2/2]

unsigned int & operator[] ( unsigned int  i)

Definition at line 89 of file Tensor.cpp.

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

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