ArmNN
 20.11
ViewsDescriptor Struct Reference

A ViewsDescriptor for the SplitterLayer. More...

#include <Descriptors.hpp>

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)
 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...
 

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

Constructor & Destructor Documentation

◆ ViewsDescriptor() [1/4]

ViewsDescriptor ( uint32_t  numViews,
uint32_t  numDimensions = 4 
)

Definition at line 221 of file Descriptors.cpp.

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

222  : m_Origins(numViews, numDimensions)
223  , m_ViewSizes(numViews > 0 && numDimensions > 0 ?
224  new uint32_t *[numViews]() : nullptr)
225 {
226  if (m_ViewSizes)
227  {
228  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
229  {
230  m_ViewSizes[i] = new uint32_t[GetNumDimensions()]();
231  }
232  }
233 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.

◆ ViewsDescriptor() [2/4]

ViewsDescriptor ( const ViewsDescriptor other)

Definition at line 235 of file Descriptors.cpp.

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

236  : m_Origins(other.m_Origins)
237  , m_ViewSizes(other.GetNumViews() > 0 && other.GetNumDimensions() > 0 ?
238  new uint32_t *[other.GetNumViews()]() : nullptr)
239 {
240  if (m_ViewSizes)
241  {
242  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
243  {
244  m_ViewSizes[i] = new uint32_t[GetNumDimensions()]();
245  memcpy(m_ViewSizes[i], other.m_ViewSizes[i], GetNumDimensions() * sizeof(uint32_t));
246  }
247  }
248 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.

◆ ViewsDescriptor() [3/4]

Definition at line 216 of file Descriptors.cpp.

217 : m_Origins()
218 , m_ViewSizes(nullptr)
219 {}

◆ ViewsDescriptor() [4/4]

Definition at line 250 of file Descriptors.cpp.

References ViewsDescriptor::swap.

251  : ViewsDescriptor()
252 {
253  swap(*this, other);
254 }
friend void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Swap the ViewsDescriptor value first and second.

◆ ~ViewsDescriptor()

Definition at line 256 of file Descriptors.cpp.

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

257 {
258  if (m_ViewSizes)
259  {
260  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
261  {
262  delete[] m_ViewSizes[i];
263  }
264  delete[] m_ViewSizes;
265  }
266 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.

Member Function Documentation

◆ GetNumDimensions()

◆ GetNumViews()

◆ GetOrigins()

const OriginsDescriptor & GetOrigins ( ) const

Get the View Origins.

Definition at line 345 of file Descriptors.cpp.

Referenced by StringifyLayerParameters< ViewsDescriptor >::Serialize(), and SerializerVisitor::VisitSplitterLayer().

346 {
347  return m_Origins;
348 }

◆ GetViewOrigin()

const uint32_t * GetViewOrigin ( uint32_t  idx) const

Get the view origin at the int value idx.

Definition at line 305 of file Descriptors.cpp.

References OriginsDescriptor::GetViewOrigin().

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

306 {
307  return m_Origins.GetViewOrigin(idx);
308 }
const uint32_t * GetViewOrigin(uint32_t idx) const
Return the view origin at the int value idx.

◆ GetViewSizes()

const uint32_t * GetViewSizes ( uint32_t  idx) const

◆ operator=()

ViewsDescriptor & operator= ( ViewsDescriptor  rhs)

Definition at line 268 of file Descriptors.cpp.

References ViewsDescriptor::swap.

269 {
270  swap(*this, rhs);
271  return *this;
272 }
friend void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Swap the ViewsDescriptor value first and second.

◆ operator==()

bool operator== ( const ViewsDescriptor rhs) const

Definition at line 274 of file Descriptors.cpp.

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

275 {
276  if (GetNumViews() != rhs.GetNumViews() || GetNumDimensions() != rhs.GetNumDimensions())
277  {
278  return false;
279  }
280 
281  for (unsigned int i = 0u; i < GetNumViews(); ++i)
282  {
283  for (unsigned int j = 0u; j < GetNumDimensions(); ++j)
284  {
285  if (GetViewOrigin(i)[j] != rhs.GetViewOrigin(i)[j] || GetViewSizes(i)[j] != rhs.GetViewSizes(i)[j])
286  {
287  return false;
288  }
289  }
290  }
291 
292  return true;
293 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.

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

References OriginsDescriptor::SetViewOriginCoord().

Referenced by CaffeParserBase::AddConvLayerWithSplits(), BOOST_AUTO_TEST_CASE(), Deserializer::GetNormalizationDescriptor(), TfLiteParser::OutputShapeOfReshape(), and armnnTfParser::OutputShapeOfSqueeze().

311 {
312  return m_Origins.SetViewOriginCoord(view, coord, value);
313 }
Status SetViewOriginCoord(uint32_t view, uint32_t coord, uint32_t value)
Set the view origin coordinates.

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

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

Referenced by CaffeParserBase::AddConvLayerWithSplits(), BOOST_AUTO_TEST_CASE(), Deserializer::GetNormalizationDescriptor(), TfLiteParser::OutputShapeOfReshape(), and armnnTfParser::OutputShapeOfSqueeze().

316 {
317  if (!m_ViewSizes)
318  {
319  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: invalid view sizes";
320  return Status::Failure;
321  }
322 
323  if (view >= GetNumViews())
324  {
325  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: view argument:" << view <<
326  " is out of range";
327  return Status::Failure;
328  }
329  if (coord >= GetNumDimensions())
330  {
331  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: coord argument:" << coord <<
332  " is out of range";
333  return Status::Failure;
334  }
335 
336  m_ViewSizes[view][coord] = value;
337  return Status::Success;
338 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163
uint32_t GetNumViews() const
Get the number of views.

Friends And Related Function Documentation

◆ swap

void swap ( ViewsDescriptor first,
ViewsDescriptor second 
)
friend

Swap the ViewsDescriptor value first and second.

Definition at line 359 of file Descriptors.cpp.

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

360 {
361  using std::swap;
362  swap(first.m_Origins, second.m_Origins);
363  swap(first.m_ViewSizes, second.m_ViewSizes);
364 }
void swap(ViewsDescriptor &first, ViewsDescriptor &second)
friend void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Swap the ViewsDescriptor value first and second.

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