ArmNN
 24.08
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 224 of file Descriptors.cpp.

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

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

◆ ViewsDescriptor() [2/4]

ViewsDescriptor ( const ViewsDescriptor other)

Definition at line 240 of file Descriptors.cpp.

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

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

◆ ViewsDescriptor() [3/4]

Definition at line 217 of file Descriptors.cpp.

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

◆ ViewsDescriptor() [4/4]

Definition at line 257 of file Descriptors.cpp.

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

References ViewsDescriptor::swap.

◆ ~ViewsDescriptor()

Definition at line 263 of file Descriptors.cpp.

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

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

Member Function Documentation

◆ GetAxis()

int32_t GetAxis ( ) const

Get the axis value.

Definition at line 382 of file Descriptors.cpp.

383 {
384  return m_Axis;
385 }

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

◆ GetNumDimensions()

◆ GetNumViews()

◆ GetOrigins()

const OriginsDescriptor & GetOrigins ( ) const

Get the View Origins.

Definition at line 352 of file Descriptors.cpp.

353 {
354  return m_Origins;
355 }

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

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

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

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

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

389 {
390  return m_IsAxisSet;
391 }

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

◆ operator=()

ViewsDescriptor & operator= ( ViewsDescriptor  rhs)

Definition at line 275 of file Descriptors.cpp.

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

References ViewsDescriptor::swap.

◆ operator==()

bool operator== ( const ViewsDescriptor rhs) const

Definition at line 281 of file Descriptors.cpp.

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

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

◆ SetAxis()

void SetAxis ( int32_t  axis)

Set the axis value.

Definition at line 375 of file Descriptors.cpp.

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

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

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

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

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

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

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

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:347
armnn::Status::Success
@ Success
armnn::ViewsDescriptor::ViewsDescriptor
ViewsDescriptor()
Definition: Descriptors.cpp:217
armnn::ViewsDescriptor::GetNumDimensions
uint32_t GetNumDimensions() const
Get the number of dimensions.
Definition: Descriptors.cpp:307
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:302
armnn::ViewsDescriptor::swap
friend void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Swap the ViewsDescriptor value first and second.
Definition: Descriptors.cpp:366
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::ViewsDescriptor::GetViewOrigin
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
Definition: Descriptors.cpp:312