ArmNN
 24.02
ViewsDescriptor Struct Reference

A ViewsDescriptor for the SplitterLayer. More...

#include <Descriptors.hpp>

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

Public Member Functions

 ViewsDescriptor (uint32_t numViews, uint32_t numDimensions=4)
 
 ViewsDescriptor (const ViewsDescriptor &other)
 
 ViewsDescriptor ()
 
 ViewsDescriptor (ViewsDescriptor &&other)
 
 ~ViewsDescriptor ()
 
ViewsDescriptoroperator= (ViewsDescriptor rhs)
 
bool operator== (const ViewsDescriptor &rhs) const
 
Status SetViewOriginCoord (uint32_t view, uint32_t coord, uint32_t value)
 @Brief Set the view origin coordinates. More...
 
Status SetViewSize (uint32_t view, uint32_t coord, uint32_t value)
 Set the size of the views. 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
 Get the view origin at the int value idx. More...
 
const uint32_t * GetViewSizes (uint32_t idx) const
 Get the view sizes at the int value idx. More...
 
const OriginsDescriptorGetOrigins () const
 Get the View Origins. More...
 
void SetAxis (int32_t axis)
 Set the axis value. More...
 
int32_t GetAxis () const
 Get the axis value. More...
 
bool HasAxis () const
 Returns true if an axis has been set. More...
 
- Public Member Functions inherited from BaseDescriptor
virtual bool IsNull () const
 
virtual ~BaseDescriptor ()=default
 

Friends

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

Detailed Description

A ViewsDescriptor for the SplitterLayer.

Descriptor to configure the splitting process. Number of Views must be equal to the number of outputs, and their order must match - e.g. first view corresponds to the first output, second view to the second output, etc.

Definition at line 244 of file Descriptors.hpp.

Constructor & Destructor Documentation

◆ ViewsDescriptor() [1/4]

ViewsDescriptor ( uint32_t  numViews,
uint32_t  numDimensions = 4 
)

Definition at line 223 of file Descriptors.cpp.

224  : m_Origins(numViews, numDimensions)
225  , m_ViewSizes(numViews > 0 && numDimensions > 0 ?
226  new uint32_t *[numViews]() : nullptr)
227  , m_IsAxisSet(false)
228  , m_Axis(0)
229 {
230  if (m_ViewSizes)
231  {
232  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
233  {
234  m_ViewSizes[i] = new uint32_t[GetNumDimensions()]();
235  }
236  }
237 }

References ViewsDescriptor::GetNumDimensions(), and ViewsDescriptor::GetNumViews().

◆ ViewsDescriptor() [2/4]

ViewsDescriptor ( const ViewsDescriptor other)

Definition at line 239 of file Descriptors.cpp.

240  : m_Origins(other.m_Origins)
241  , m_ViewSizes(other.GetNumViews() > 0 && other.GetNumDimensions() > 0 ?
242  new uint32_t *[other.GetNumViews()]() : nullptr)
243  , m_IsAxisSet(other.m_IsAxisSet)
244  , m_Axis(other.m_Axis)
245 {
246  if (m_ViewSizes)
247  {
248  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
249  {
250  m_ViewSizes[i] = new uint32_t[GetNumDimensions()]();
251  memcpy(m_ViewSizes[i], other.m_ViewSizes[i], GetNumDimensions() * sizeof(uint32_t));
252  }
253  }
254 }

References ViewsDescriptor::GetNumDimensions(), and ViewsDescriptor::GetNumViews().

◆ ViewsDescriptor() [3/4]

Definition at line 216 of file Descriptors.cpp.

217 : m_Origins()
218 , m_ViewSizes(nullptr)
219 , m_IsAxisSet(false)
220 , m_Axis(0)
221 {}

◆ ViewsDescriptor() [4/4]

Definition at line 256 of file Descriptors.cpp.

257  : ViewsDescriptor()
258 {
259  swap(*this, other);
260 }

References ViewsDescriptor::swap.

◆ ~ViewsDescriptor()

Definition at line 262 of file Descriptors.cpp.

263 {
264  if (m_ViewSizes)
265  {
266  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
267  {
268  delete[] m_ViewSizes[i];
269  }
270  delete[] m_ViewSizes;
271  }
272 }

References ViewsDescriptor::GetNumDimensions(), and ViewsDescriptor::GetNumViews().

Member Function Documentation

◆ GetAxis()

int32_t GetAxis ( ) const

Get the axis value.

Definition at line 381 of file Descriptors.cpp.

382 {
383  return m_Axis;
384 }

Referenced by armnn::ComputeSplitAxis(), and StringifyLayerParameters< ViewsDescriptor >::Serialize().

◆ GetNumDimensions()

◆ GetNumViews()

◆ GetOrigins()

const OriginsDescriptor & GetOrigins ( ) const

Get the View Origins.

Definition at line 351 of file Descriptors.cpp.

352 {
353  return m_Origins;
354 }

Referenced by StringifyLayerParameters< ViewsDescriptor >::Serialize().

◆ GetViewOrigin()

const uint32_t * GetViewOrigin ( uint32_t  idx) const

Get the view origin at the int value idx.

Definition at line 311 of file Descriptors.cpp.

312 {
313  return m_Origins.GetViewOrigin(idx);
314 }

References OriginsDescriptor::GetViewOrigin().

Referenced by SplitterLayer::CreateWorkload(), and ViewsDescriptor::operator==().

◆ GetViewSizes()

const uint32_t * GetViewSizes ( uint32_t  idx) const

Get the view sizes at the int value idx.

Definition at line 346 of file Descriptors.cpp.

347 {
348  return m_ViewSizes ? m_ViewSizes[idx] : nullptr;
349 }

Referenced by armnn::ComputeSplitAxis(), SplitterLayer::InferOutputShapes(), ViewsDescriptor::operator==(), StringifyLayerParameters< ViewsDescriptor >::Serialize(), and SplitterLayer::ValidateTensorShapesFromInputs().

◆ HasAxis()

bool HasAxis ( ) const

Returns true if an axis has been set.

Definition at line 387 of file Descriptors.cpp.

388 {
389  return m_IsAxisSet;
390 }

Referenced by armnn::ComputeSplitAxis(), and StringifyLayerParameters< ViewsDescriptor >::Serialize().

◆ operator=()

ViewsDescriptor & operator= ( ViewsDescriptor  rhs)

Definition at line 274 of file Descriptors.cpp.

275 {
276  swap(*this, rhs);
277  return *this;
278 }

References ViewsDescriptor::swap.

◆ operator==()

bool operator== ( const ViewsDescriptor rhs) const

Definition at line 280 of file Descriptors.cpp.

281 {
282  if (GetNumViews() != rhs.GetNumViews() || GetNumDimensions() != rhs.GetNumDimensions())
283  {
284  return false;
285  }
286 
287  for (unsigned int i = 0u; i < GetNumViews(); ++i)
288  {
289  for (unsigned int j = 0u; j < GetNumDimensions(); ++j)
290  {
291  if (GetViewOrigin(i)[j] != rhs.GetViewOrigin(i)[j] || GetViewSizes(i)[j] != rhs.GetViewSizes(i)[j])
292  {
293  return false;
294  }
295  }
296  }
297 
298  return true;
299 }

References ViewsDescriptor::GetNumDimensions(), ViewsDescriptor::GetNumViews(), ViewsDescriptor::GetViewOrigin(), and ViewsDescriptor::GetViewSizes().

◆ SetAxis()

void SetAxis ( int32_t  axis)

Set the axis value.

Definition at line 374 of file Descriptors.cpp.

375 {
376  m_Axis = axis;
377  m_IsAxisSet = true;
378 }

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

317 {
318  return m_Origins.SetViewOriginCoord(view, coord, value);
319 }

References OriginsDescriptor::SetViewOriginCoord().

◆ SetViewSize()

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

Set the size of the views.

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

322 {
323  if (!m_ViewSizes)
324  {
325  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: invalid view sizes";
326  return Status::Failure;
327  }
328 
329  if (view >= GetNumViews())
330  {
331  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: view argument:" << view <<
332  " is out of range";
333  return Status::Failure;
334  }
335  if (coord >= GetNumDimensions())
336  {
337  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: coord argument:" << coord <<
338  " is out of range";
339  return Status::Failure;
340  }
341 
342  m_ViewSizes[view][coord] = value;
343  return Status::Success;
344 }

References ARMNN_LOG, armnn::error, armnn::Failure, ViewsDescriptor::GetNumDimensions(), ViewsDescriptor::GetNumViews(), and armnn::Success.

Friends And Related Function Documentation

◆ swap

void swap ( ViewsDescriptor first,
ViewsDescriptor second 
)
friend

Swap the ViewsDescriptor value first and second.

Definition at line 365 of file Descriptors.cpp.

366 {
367  using std::swap;
368  swap(first.m_Origins, second.m_Origins);
369  swap(first.m_ViewSizes, second.m_ViewSizes);
370  swap(first.m_IsAxisSet, second.m_IsAxisSet);
371  swap(first.m_Axis, second.m_Axis);
372 }

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


The documentation for this struct was generated from the following files:
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::ViewsDescriptor::GetViewSizes
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
Definition: Descriptors.cpp:346
armnn::Status::Success
@ Success
armnn::ViewsDescriptor::ViewsDescriptor
ViewsDescriptor()
Definition: Descriptors.cpp:216
armnn::ViewsDescriptor::GetNumDimensions
uint32_t GetNumDimensions() const
Get the number of dimensions.
Definition: Descriptors.cpp:306
armnn::OriginsDescriptor::SetViewOriginCoord
Status SetViewOriginCoord(uint32_t view, uint32_t coord, uint32_t value)
@Brief Set the view origin coordinates.
Definition: Descriptors.cpp:167
armnn::ViewsDescriptor::GetNumViews
uint32_t GetNumViews() const
Get the number of views.
Definition: Descriptors.cpp:301
armnn::ViewsDescriptor::swap
friend void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Swap the ViewsDescriptor value first and second.
Definition: Descriptors.cpp:365
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:365
armnn::Status::Failure
@ Failure
armnn::ViewsDescriptor::GetViewOrigin
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
Definition: Descriptors.cpp:311