ArmNN
 20.02
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 190 of file Descriptors.hpp.

Constructor & Destructor Documentation

◆ ViewsDescriptor() [1/4]

ViewsDescriptor ( uint32_t  numViews,
uint32_t  numDimensions = 4 
)

Definition at line 213 of file Descriptors.cpp.

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

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

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

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

◆ ViewsDescriptor() [3/4]

Definition at line 208 of file Descriptors.cpp.

209 : m_Origins()
210 , m_ViewSizes(nullptr)
211 {}

◆ ViewsDescriptor() [4/4]

Definition at line 242 of file Descriptors.cpp.

References ViewsDescriptor::swap.

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

◆ ~ViewsDescriptor()

Definition at line 248 of file Descriptors.cpp.

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

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

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

338 {
339  return m_Origins;
340 }

◆ GetViewOrigin()

const uint32_t * GetViewOrigin ( uint32_t  idx) const

Get the view origin at the int value idx.

Definition at line 297 of file Descriptors.cpp.

References OriginsDescriptor::GetViewOrigin().

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

298 {
299  return m_Origins.GetViewOrigin(idx);
300 }
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 332 of file Descriptors.cpp.

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

333 {
334  return m_ViewSizes ? m_ViewSizes[idx] : nullptr;
335 }

◆ operator=()

ViewsDescriptor & operator= ( ViewsDescriptor  rhs)

Definition at line 260 of file Descriptors.cpp.

References ViewsDescriptor::swap.

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

◆ operator==()

bool operator== ( const ViewsDescriptor rhs) const

Definition at line 266 of file Descriptors.cpp.

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

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

References OriginsDescriptor::SetViewOriginCoord().

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

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

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

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

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