ArmNN
 24.08
OriginsDescriptor Struct Reference

An OriginsDescriptor for the ConcatLayer. More...

#include <Descriptors.hpp>

Inheritance diagram for OriginsDescriptor:
[legend]
Collaboration diagram for OriginsDescriptor:
[legend]

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)
 @Brief 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...
 
- Public Member Functions inherited from BaseDescriptor
virtual bool IsNull () const
 
virtual ~BaseDescriptor ()=default
 

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

Constructor & Destructor Documentation

◆ OriginsDescriptor() [1/4]

Definition at line 82 of file Descriptors.cpp.

83 : m_ConcatAxis(1)
84 , m_NumViews(0)
85 , m_NumDimensions(0)
86 , m_ViewOrigins(nullptr)
87 {}

◆ OriginsDescriptor() [2/4]

OriginsDescriptor ( uint32_t  numViews,
uint32_t  numDimensions = 4 
)

Definition at line 89 of file Descriptors.cpp.

90 : m_ConcatAxis(1)
91 , m_NumViews(numViews)
92 , m_NumDimensions(numDimensions)
93 , m_ViewOrigins(numViews && numDimensions > 0 ? new uint32_t *[numViews]() : nullptr)
94 {
95  for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
96  {
97  m_ViewOrigins[i] = new uint32_t[m_NumDimensions]();
98  }
99 }

◆ OriginsDescriptor() [3/4]

Definition at line 101 of file Descriptors.cpp.

102 : m_ConcatAxis(other.m_ConcatAxis)
103 , m_NumViews(other.m_NumViews)
104 , m_NumDimensions(other.m_NumDimensions)
105 , m_ViewOrigins(other.m_NumViews && other.m_NumDimensions > 0 ? new uint32_t *[other.m_NumViews]() : nullptr)
106 {
107  for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
108  {
109  m_ViewOrigins[i] = new uint32_t[m_NumDimensions]();
110  memcpy(m_ViewOrigins[i], other.m_ViewOrigins[i], m_NumDimensions * sizeof(uint32_t));
111  }
112 }

◆ OriginsDescriptor() [4/4]

Definition at line 114 of file Descriptors.cpp.

116 {
117  swap(*this, other);
118 }

References OriginsDescriptor::swap.

◆ ~OriginsDescriptor()

Definition at line 120 of file Descriptors.cpp.

121 {
122  for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
123  {
124  delete[] m_ViewOrigins[i];
125  }
126  delete[] m_ViewOrigins;
127 }

Member Function Documentation

◆ GetConcatAxis()

unsigned int GetConcatAxis ( ) const

◆ GetNumDimensions()

◆ GetNumViews()

◆ GetViewOrigin()

const uint32_t * GetViewOrigin ( uint32_t  idx) const

Return the view origin at the int value idx.

Definition at line 197 of file Descriptors.cpp.

198 {
199  return m_ViewOrigins ? m_ViewOrigins[idx] : nullptr;
200 }

Referenced by ConcatLayer::CreateWorkload(), ViewsDescriptor::GetViewOrigin(), ConcatLayer::InferOutputShapes(), OriginsDescriptor::operator==(), and StringifyLayerParameters< OriginsDescriptor >::Serialize().

◆ operator=()

OriginsDescriptor & operator= ( OriginsDescriptor  rhs)

Definition at line 129 of file Descriptors.cpp.

130 {
131  swap(*this, rhs);
132  return *this;
133 }

References OriginsDescriptor::swap.

◆ operator==()

bool operator== ( const OriginsDescriptor rhs) const

Definition at line 135 of file Descriptors.cpp.

136 {
137  if (GetNumViews() != rhs.GetNumViews() ||
138  GetNumDimensions() != rhs.GetNumDimensions() ||
139  GetConcatAxis() != rhs.GetConcatAxis())
140  {
141  return false;
142  }
143 
144  for (unsigned int i = 0u; i < GetNumViews(); ++i)
145  {
146  for (unsigned int j = 0u; j < GetNumDimensions(); ++j)
147  {
148  if (GetViewOrigin(i)[j] != rhs.GetViewOrigin(i)[j])
149  {
150  return false;
151  }
152  }
153  }
154 
155  return true;
156 }

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

◆ 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 204 of file Descriptors.cpp.

205 {
206  ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(m_NumViews == numNewOrdering,
207  "number of views must match number of elements in the new ordering array");
208 
209  std::vector<uint32_t*> viewOrigins(&m_ViewOrigins[0], &m_ViewOrigins[m_NumViews]);
210 
211  for (unsigned int i = 0; i < numNewOrdering; ++i)
212  {
213  m_ViewOrigins[i] = viewOrigins[newOrdering[i]];
214  }
215 }

References ARMNN_THROW_INVALIDARG_MSG_IF_FALSE.

◆ SetConcatAxis()

void SetConcatAxis ( unsigned int  concatAxis)

Set the concatenation axis value.

Definition at line 158 of file Descriptors.cpp.

159 {
160  m_ConcatAxis = concatAxis;
161 }

Referenced by armnn::CreateDescriptorForConcatenation().

◆ SetViewOriginCoord()

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

@Brief 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 167 of file Descriptors.cpp.

168 {
169  if (view >= m_NumViews)
170  {
171  ARMNN_LOG(error) << "OriginsDescriptor::SetViewOriginCoord: view argument:" << view <<
172  " is out of range";
173  return Status::Failure;
174  }
175  if (coord >= m_NumDimensions)
176  {
177  ARMNN_LOG(error) << "OriginsDescriptor::SetViewOriginCoord: coord argument:" << coord <<
178  " is out of range";
179  return Status::Failure;
180  }
181 
182  m_ViewOrigins[view][coord] = value;
183  return Status::Success;
184 }

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

Referenced by armnn::CreateDescriptorForConcatenation(), armnnUtils::ProcessConcatInputTensorInfo(), and ViewsDescriptor::SetViewOriginCoord().

Friends And Related Function Documentation

◆ swap

void swap ( OriginsDescriptor first,
OriginsDescriptor second 
)
friend

Swap the ViewsDescriptor values first and second.

Definition at line 357 of file Descriptors.cpp.

358 {
359  using std::swap;
360  swap(first.m_NumViews, second.m_NumViews);
361  swap(first.m_NumDimensions, second.m_NumDimensions);
362  swap(first.m_ViewOrigins, second.m_ViewOrigins);
363  swap(first.m_ConcatAxis, second.m_ConcatAxis);
364 }

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


The documentation for this struct was generated from the following files:
armnn::OriginsDescriptor::GetConcatAxis
unsigned int GetConcatAxis() const
Get the concatenation axis value.
Definition: Descriptors.cpp:162
armnn::OriginsDescriptor::GetNumViews
uint32_t GetNumViews() const
Get the number of views.
Definition: Descriptors.cpp:187
armnn::OriginsDescriptor::GetNumDimensions
uint32_t GetNumDimensions() const
Get the number of dimensions.
Definition: Descriptors.cpp:192
ARMNN_LOG
#define ARMNN_LOG(severity)
Definition: Logging.hpp:212
armnn::OriginsDescriptor::swap
friend void swap(OriginsDescriptor &first, OriginsDescriptor &second)
Swap the ViewsDescriptor values first and second.
Definition: Descriptors.cpp:357
armnn::Status::Success
@ Success
armnn::OriginsDescriptor::OriginsDescriptor
OriginsDescriptor()
Definition: Descriptors.cpp:82
armnn::OriginsDescriptor::GetViewOrigin
const uint32_t * GetViewOrigin(uint32_t idx) const
Return the view origin at the int value idx.
Definition: Descriptors.cpp:197
armnn::swap
void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Definition: Descriptors.cpp:366
armnn::Status::Failure
@ Failure
ARMNN_THROW_INVALIDARG_MSG_IF_FALSE
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
Definition: Exceptions.hpp:210