ArmNN
 20.02
OriginsDescriptor Struct Reference

An OriginsDescriptor for the ConcatLayer. More...

#include <Descriptors.hpp>

Public Member Functions

 OriginsDescriptor ()
 
 OriginsDescriptor (uint32_t numViews, uint32_t numDimensions=4)
 
 OriginsDescriptor (const OriginsDescriptor &other)
 
 OriginsDescriptor (OriginsDescriptor &&other)
 
 ~OriginsDescriptor ()
 
OriginsDescriptoroperator= (OriginsDescriptor rhs)
 
bool operator== (const OriginsDescriptor &rhs) const
 
Status SetViewOriginCoord (uint32_t view, uint32_t coord, uint32_t value)
 Set the view origin coordinates. More...
 
uint32_t GetNumViews () const
 Get the number of views. More...
 
uint32_t GetNumDimensions () const
 Get the number of dimensions. More...
 
const uint32_t * GetViewOrigin (uint32_t idx) const
 Return the view origin at the int value idx. More...
 
void ReorderOrigins (unsigned int *newOrdering, unsigned int numNewOrdering)
 Reorders the viewOrigins in accordance with the indices presented in newOrdering array. More...
 
void SetConcatAxis (unsigned int concatAxis)
 Set the concatenation axis value. More...
 
unsigned int GetConcatAxis () const
 Get the concatenation axis value. More...
 

Friends

void swap (OriginsDescriptor &first, OriginsDescriptor &second)
 Swap the ViewsDescriptor values first and second. More...
 

Detailed Description

An OriginsDescriptor for the ConcatLayer.

Descriptor to configure the concatenation process. Number of views must be equal to the number of inputs, and their order must match - e.g. first view corresponds to the first input, second view to the second input, etc.

Definition at line 147 of file Descriptors.hpp.

Constructor & Destructor Documentation

◆ OriginsDescriptor() [1/4]

Definition at line 74 of file Descriptors.cpp.

75 : m_ConcatAxis(1)
76 , m_NumViews(0)
77 , m_NumDimensions(0)
78 , m_ViewOrigins(nullptr)
79 {}

◆ OriginsDescriptor() [2/4]

OriginsDescriptor ( uint32_t  numViews,
uint32_t  numDimensions = 4 
)

Definition at line 81 of file Descriptors.cpp.

82 : m_ConcatAxis(1)
83 , m_NumViews(numViews)
84 , m_NumDimensions(numDimensions)
85 , m_ViewOrigins(numViews && numDimensions > 0 ? new uint32_t *[numViews]() : nullptr)
86 {
87  for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
88  {
89  m_ViewOrigins[i] = new uint32_t[m_NumDimensions]();
90  }
91 }

◆ OriginsDescriptor() [3/4]

Definition at line 93 of file Descriptors.cpp.

94 : m_ConcatAxis(other.m_ConcatAxis)
95 , m_NumViews(other.m_NumViews)
96 , m_NumDimensions(other.m_NumDimensions)
97 , m_ViewOrigins(other.m_NumViews && other.m_NumDimensions > 0 ? new uint32_t *[other.m_NumViews]() : nullptr)
98 {
99  for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
100  {
101  m_ViewOrigins[i] = new uint32_t[m_NumDimensions]();
102  memcpy(m_ViewOrigins[i], other.m_ViewOrigins[i], m_NumDimensions * sizeof(uint32_t));
103  }
104 }

◆ OriginsDescriptor() [4/4]

Definition at line 106 of file Descriptors.cpp.

References OriginsDescriptor::swap.

108 {
109  swap(*this, other);
110 }
friend void swap(OriginsDescriptor &first, OriginsDescriptor &second)
Swap the ViewsDescriptor values first and second.

◆ ~OriginsDescriptor()

Definition at line 112 of file Descriptors.cpp.

113 {
114  for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
115  {
116  delete[] m_ViewOrigins[i];
117  }
118  delete[] m_ViewOrigins;
119 }

Member Function Documentation

◆ GetConcatAxis()

unsigned int GetConcatAxis ( ) const

◆ GetNumDimensions()

◆ GetNumViews()

◆ GetViewOrigin()

const uint32_t * GetViewOrigin ( uint32_t  idx) const

◆ operator=()

OriginsDescriptor & operator= ( OriginsDescriptor  rhs)

Definition at line 121 of file Descriptors.cpp.

References OriginsDescriptor::swap.

122 {
123  swap(*this, rhs);
124  return *this;
125 }
friend void swap(OriginsDescriptor &first, OriginsDescriptor &second)
Swap the ViewsDescriptor values first and second.

◆ operator==()

bool operator== ( const OriginsDescriptor rhs) const

Definition at line 127 of file Descriptors.cpp.

References OriginsDescriptor::GetConcatAxis(), OriginsDescriptor::GetNumDimensions(), OriginsDescriptor::GetNumViews(), and OriginsDescriptor::GetViewOrigin().

128 {
129  if (GetNumViews() != rhs.GetNumViews() ||
130  GetNumDimensions() != rhs.GetNumDimensions() ||
131  GetConcatAxis() != rhs.GetConcatAxis())
132  {
133  return false;
134  }
135 
136  for (unsigned int i = 0u; i < GetNumViews(); ++i)
137  {
138  for (unsigned int j = 0u; j < GetNumDimensions(); ++j)
139  {
140  if (GetViewOrigin(i)[j] != rhs.GetViewOrigin(i)[j])
141  {
142  return false;
143  }
144  }
145  }
146 
147  return true;
148 }
const uint32_t * GetViewOrigin(uint32_t idx) const
Return the view origin at the int value idx.
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.
unsigned int GetConcatAxis() const
Get the concatenation axis value.

◆ ReorderOrigins()

void ReorderOrigins ( unsigned int *  newOrdering,
unsigned int  numNewOrdering 
)

Reorders the viewOrigins in accordance with the indices presented in newOrdering array.

The number of views must match number of elements in the new ordering array.

Definition at line 196 of file Descriptors.cpp.

197 {
198  BOOST_ASSERT_MSG(m_NumViews == numNewOrdering, "number of views must match number of "
199  "elements in the new ordering array");
200  std::vector<uint32_t*> viewOrigins(&m_ViewOrigins[0], &m_ViewOrigins[m_NumViews]);
201 
202  for (unsigned int i = 0; i < numNewOrdering; ++i)
203  {
204  m_ViewOrigins[i] = viewOrigins[newOrdering[i]];
205  }
206 }

◆ SetConcatAxis()

void SetConcatAxis ( unsigned int  concatAxis)

Set the concatenation axis value.

Definition at line 150 of file Descriptors.cpp.

Referenced by armnnTfParser::CalculatePaddedOutputTensorInfo(), armnn::CreateDescriptorForConcatenation(), and TfLiteParser::OutputShapeOfReshape().

151 {
152  m_ConcatAxis = concatAxis;
153 }

◆ SetViewOriginCoord()

Status SetViewOriginCoord ( uint32_t  view,
uint32_t  coord,
uint32_t  value 
)

Set the view origin coordinates.

The arguments are: view, dimension, value. If the view is greater than or equal to GetNumViews(), then the view argument is out of range. If the coord is greater than or equal to GetNumDimensions(), then the coord argument is out of range.

Definition at line 159 of file Descriptors.cpp.

References ARMNN_LOG, armnn::error, armnn::Failure, and armnn::Success.

Referenced by CaffeParserBase::AddConvLayerWithSplits(), armnnTfParser::CalculatePaddedOutputTensorInfo(), armnn::CreateDescriptorForConcatenation(), CaffeParserBase::ParseConcatLayer(), armnnUtils::ProcessConcatInputTensorInfo(), and ViewsDescriptor::SetViewOriginCoord().

160 {
161  if (view >= m_NumViews)
162  {
163  ARMNN_LOG(error) << "OriginsDescriptor::SetViewOriginCoord: view argument:" << view <<
164  " is out of range";
165  return Status::Failure;
166  }
167  if (coord >= m_NumDimensions)
168  {
169  ARMNN_LOG(error) << "OriginsDescriptor::SetViewOriginCoord: coord argument:" << coord <<
170  " is out of range";
171  return Status::Failure;
172  }
173 
174  m_ViewOrigins[view][coord] = value;
175  return Status::Success;
176 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163

Friends And Related Function Documentation

◆ swap

void swap ( OriginsDescriptor first,
OriginsDescriptor second 
)
friend

Swap the ViewsDescriptor values first and second.

Definition at line 342 of file Descriptors.cpp.

Referenced by OriginsDescriptor::operator=(), and OriginsDescriptor::OriginsDescriptor().

343 {
344  using std::swap;
345  swap(first.m_NumViews, second.m_NumViews);
346  swap(first.m_NumDimensions, second.m_NumDimensions);
347  swap(first.m_ViewOrigins, second.m_ViewOrigins);
348  swap(first.m_ConcatAxis, second.m_ConcatAxis);
349 }
friend void swap(OriginsDescriptor &first, OriginsDescriptor &second)
Swap the ViewsDescriptor values first and second.
void swap(ViewsDescriptor &first, ViewsDescriptor &second)

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