ArmNN
 20.05
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 198 of file Descriptors.hpp.

Constructor & Destructor Documentation

◆ ViewsDescriptor() [1/4]

ViewsDescriptor ( uint32_t  numViews,
uint32_t  numDimensions = 4 
)

Definition at line 215 of file Descriptors.cpp.

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

216  : m_Origins(numViews, numDimensions)
217  , m_ViewSizes(numViews > 0 && numDimensions > 0 ?
218  new uint32_t *[numViews]() : nullptr)
219 {
220  if (m_ViewSizes)
221  {
222  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
223  {
224  m_ViewSizes[i] = new uint32_t[GetNumDimensions()]();
225  }
226  }
227 }
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 229 of file Descriptors.cpp.

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

230  : m_Origins(other.m_Origins)
231  , m_ViewSizes(other.GetNumViews() > 0 && other.GetNumDimensions() > 0 ?
232  new uint32_t *[other.GetNumViews()]() : nullptr)
233 {
234  if (m_ViewSizes)
235  {
236  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
237  {
238  m_ViewSizes[i] = new uint32_t[GetNumDimensions()]();
239  memcpy(m_ViewSizes[i], other.m_ViewSizes[i], GetNumDimensions() * sizeof(uint32_t));
240  }
241  }
242 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.

◆ ViewsDescriptor() [3/4]

Definition at line 210 of file Descriptors.cpp.

211 : m_Origins()
212 , m_ViewSizes(nullptr)
213 {}

◆ ViewsDescriptor() [4/4]

Definition at line 244 of file Descriptors.cpp.

References ViewsDescriptor::swap.

245  : ViewsDescriptor()
246 {
247  swap(*this, other);
248 }
friend void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Swap the ViewsDescriptor value first and second.

◆ ~ViewsDescriptor()

Definition at line 250 of file Descriptors.cpp.

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

251 {
252  if (m_ViewSizes)
253  {
254  for (uint32_t i = 0; GetNumDimensions() > 0 && i < GetNumViews(); ++i)
255  {
256  delete[] m_ViewSizes[i];
257  }
258  delete[] m_ViewSizes;
259  }
260 }
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 339 of file Descriptors.cpp.

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

340 {
341  return m_Origins;
342 }

◆ GetViewOrigin()

const uint32_t * GetViewOrigin ( uint32_t  idx) const

Get the view origin at the int value idx.

Definition at line 299 of file Descriptors.cpp.

References OriginsDescriptor::GetViewOrigin().

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

300 {
301  return m_Origins.GetViewOrigin(idx);
302 }
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

Get the view sizes at the int value idx.

Definition at line 334 of file Descriptors.cpp.

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

335 {
336  return m_ViewSizes ? m_ViewSizes[idx] : nullptr;
337 }

◆ operator=()

ViewsDescriptor & operator= ( ViewsDescriptor  rhs)

Definition at line 262 of file Descriptors.cpp.

References ViewsDescriptor::swap.

263 {
264  swap(*this, rhs);
265  return *this;
266 }
friend void swap(ViewsDescriptor &first, ViewsDescriptor &second)
Swap the ViewsDescriptor value first and second.

◆ operator==()

bool operator== ( const ViewsDescriptor rhs) const

Definition at line 268 of file Descriptors.cpp.

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

269 {
270  if (GetNumViews() != rhs.GetNumViews() || GetNumDimensions() != rhs.GetNumDimensions())
271  {
272  return false;
273  }
274 
275  for (unsigned int i = 0u; i < GetNumViews(); ++i)
276  {
277  for (unsigned int j = 0u; j < GetNumDimensions(); ++j)
278  {
279  if (GetViewOrigin(i)[j] != rhs.GetViewOrigin(i)[j] || GetViewSizes(i)[j] != rhs.GetViewSizes(i)[j])
280  {
281  return false;
282  }
283  }
284  }
285 
286  return true;
287 }
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 304 of file Descriptors.cpp.

References OriginsDescriptor::SetViewOriginCoord().

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

305 {
306  return m_Origins.SetViewOriginCoord(view, coord, value);
307 }
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 309 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().

310 {
311  if (!m_ViewSizes)
312  {
313  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: invalid view sizes";
314  return Status::Failure;
315  }
316 
317  if (view >= GetNumViews())
318  {
319  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: view argument:" << view <<
320  " is out of range";
321  return Status::Failure;
322  }
323  if (coord >= GetNumDimensions())
324  {
325  ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: coord argument:" << coord <<
326  " is out of range";
327  return Status::Failure;
328  }
329 
330  m_ViewSizes[view][coord] = value;
331  return Status::Success;
332 }
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 353 of file Descriptors.cpp.

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

354 {
355  using std::swap;
356  swap(first.m_Origins, second.m_Origins);
357  swap(first.m_ViewSizes, second.m_ViewSizes);
358 }
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: