Compute Library
 22.05
CLArrayAccessor< T > Class Template Reference

Accessor implementation for CLArray objects. More...

#include <CLArrayAccessor.h>

Collaboration diagram for CLArrayAccessor< T >:
[legend]

Public Member Functions

 CLArrayAccessor (CLArray< T > &array)
 Create an accessor for the given array. More...
 
 CLArrayAccessor (const CLArrayAccessor &)=delete
 Prevent instances of this class from being copy constructed. More...
 
CLArrayAccessoroperator= (const CLArrayAccessor &)=delete
 Prevent instances of this class from being copied. More...
 
 CLArrayAccessor (CLArrayAccessor &&)=default
 Allow instances of this class to be move constructed. More...
 
CLArrayAccessoroperator= (CLArrayAccessor &&)=default
 Allow instances of this class to be moved. More...
 
 ~CLArrayAccessor ()
 Destructor that unmaps the CL memory. More...
 
size_t num_values () const override
 Number of elements of the tensor. More...
 
T * buffer () override
 Access to the buffer. More...
 
void resize (size_t num) override
 Resize array. More...
 
T & at (size_t index) const override
 Reference to the element of the array located at the given index. More...
 
- Public Member Functions inherited from IArrayAccessor< T >
virtual ~IArrayAccessor ()=default
 Virtual destructor. More...
 

Additional Inherited Members

- Public Types inherited from IArrayAccessor< T >
using value_type = T
 Array value type. More...
 

Detailed Description

template<typename T>
class arm_compute::test::CLArrayAccessor< T >

Accessor implementation for CLArray objects.

Definition at line 36 of file CLArrayAccessor.h.

Constructor & Destructor Documentation

◆ CLArrayAccessor() [1/3]

CLArrayAccessor ( CLArray< T > &  array)
inline

Create an accessor for the given array.

Parameters
[in,out]arrayTo be accessed array.
Note
The CL memory is mapped by the constructor.

Definition at line 46 of file CLArrayAccessor.h.

References CLArrayAccessor< T >::operator=().

47  : _array{ array }
48  {
49  _array.map();
50  }

◆ CLArrayAccessor() [2/3]

CLArrayAccessor ( const CLArrayAccessor< T > &  )
delete

Prevent instances of this class from being copy constructed.

◆ CLArrayAccessor() [3/3]

CLArrayAccessor ( CLArrayAccessor< T > &&  )
default

Allow instances of this class to be move constructed.

◆ ~CLArrayAccessor()

~CLArrayAccessor ( )
inline

Destructor that unmaps the CL memory.

Definition at line 62 of file CLArrayAccessor.h.

63  {
64  _array.unmap();
65  }

Member Function Documentation

◆ at()

T& at ( size_t  index) const
inlineoverridevirtual

Reference to the element of the array located at the given index.

Parameters
[in]indexIndex of the element
Returns
A reference to the element of the array located at the given index.

Implements IArrayAccessor< T >.

Definition at line 82 of file CLArrayAccessor.h.

References ARM_COMPUTE_ERROR_ON, and CLArrayAccessor< T >::num_values().

83  {
84  ARM_COMPUTE_ERROR_ON(_array.buffer() == nullptr);
85  ARM_COMPUTE_ERROR_ON(index >= num_values());
86  return _array.buffer()[index];
87  }
size_t num_values() const override
Number of elements of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ buffer()

T* buffer ( )
inlineoverridevirtual

Access to the buffer.

Returns
A pointer to the first element in the buffer.

Implements IArrayAccessor< T >.

Definition at line 72 of file CLArrayAccessor.h.

73  {
74  return _array.buffer();
75  }

◆ num_values()

size_t num_values ( ) const
inlineoverridevirtual

Number of elements of the tensor.

Returns
the number of elements.

Implements IArrayAccessor< T >.

Definition at line 67 of file CLArrayAccessor.h.

Referenced by CLArrayAccessor< T >::at().

68  {
69  return _array.num_values();
70  }

◆ operator=() [1/2]

CLArrayAccessor& operator= ( const CLArrayAccessor< T > &  )
delete

Prevent instances of this class from being copied.

Referenced by CLArrayAccessor< T >::CLArrayAccessor().

◆ operator=() [2/2]

CLArrayAccessor& operator= ( CLArrayAccessor< T > &&  )
default

Allow instances of this class to be moved.

◆ resize()

void resize ( size_t  num)
inlineoverridevirtual

Resize array.

Parameters
[in]numThe new array size in number of elements

Implements IArrayAccessor< T >.

Definition at line 77 of file CLArrayAccessor.h.

78  {
79  _array.resize(num);
80  }

The documentation for this class was generated from the following file: