Compute Library
 19.08
ICLTensor Class Referenceabstract

Interface for OpenCL tensor. More...

#include <ICLTensor.h>

Collaboration diagram for ICLTensor:
[legend]

Public Member Functions

 ICLTensor ()
 Default constructor. More...
 
 ICLTensor (const ICLTensor &)=delete
 Prevent instances of this class from being copy constructed. More...
 
ICLTensoroperator= (const ICLTensor &)=delete
 Prevent instances of this class from being copied. More...
 
 ICLTensor (ICLTensor &&)=default
 Allow instances of this class to be move constructed. More...
 
ICLTensoroperator= (ICLTensor &&)=default
 Allow instances of this class to be copied. More...
 
virtual ~ICLTensor ()=default
 Default virtual destructor. More...
 
virtual CLQuantization quantization () const =0
 Interface to be implemented by the child class to return the wrapped quantization info data. More...
 
virtual const cl::Buffer & cl_buffer () const =0
 Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the image's data. More...
 
void map (cl::CommandQueue &q, bool blocking=true)
 Enqueue a map operation of the allocated buffer on the given queue. More...
 
void unmap (cl::CommandQueue &q)
 Enqueue an unmap operation of the allocated and mapped buffer on the given queue. More...
 
void clear (cl::CommandQueue &q)
 Clear the contents of the tensor synchronously. More...
 
uint8_t * buffer () const override
 Interface to be implemented by the child class to return a pointer to CPU memory. More...
 
- Public Member Functions inherited from ITensor
virtual ITensorInfoinfo () const =0
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
virtual ITensorInfoinfo ()=0
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
virtual ~ITensor ()=default
 Default virtual destructor. More...
 
uint8_t * ptr_to_element (const Coordinates &id) const
 Return a pointer to the element at the passed coordinates. More...
 
void copy_from (const ITensor &src)
 Copy the content of another tensor. More...
 
void print (std::ostream &s, IOFormatInfo io_fmt=IOFormatInfo()) const
 Print a tensor to a given stream using user defined formatting information. More...
 
bool is_used () const
 Flags if the tensor is used or not. More...
 
void mark_as_unused () const
 Marks a tensor as unused. More...
 

Detailed Description

Interface for OpenCL tensor.

Definition at line 42 of file ICLTensor.h.

Constructor & Destructor Documentation

◆ ICLTensor() [1/3]

ICLTensor ( )

Default constructor.

Definition at line 30 of file ICLTensor.cpp.

31  : _mapping(nullptr)
32 {
33 }

◆ ICLTensor() [2/3]

ICLTensor ( const ICLTensor )
delete

Prevent instances of this class from being copy constructed.

◆ ICLTensor() [3/3]

ICLTensor ( ICLTensor &&  )
default

Allow instances of this class to be move constructed.

◆ ~ICLTensor()

virtual ~ICLTensor ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ buffer()

uint8_t * buffer ( ) const
overridevirtual

Interface to be implemented by the child class to return a pointer to CPU memory.

Returns
A CPU pointer to the beginning of the image's allocation.

Implements ITensor.

Definition at line 53 of file ICLTensor.cpp.

54 {
55  return _mapping;
56 }

Referenced by CLFFT1D::configure(), CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), and CLAccessor::data().

◆ cl_buffer()

virtual const cl::Buffer& cl_buffer ( ) const
pure virtual

Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the image's data.

Returns
A reference to an OpenCL buffer containing the image's data.

Implemented in CLSubTensor, and CLTensor.

Referenced by ICLKernel::add_tensor_argument(), and CLSubTensor::cl_buffer().

◆ clear()

void clear ( cl::CommandQueue &  q)

Clear the contents of the tensor synchronously.

Parameters
[in,out]qThe CL command queue to use for the clear operation.

Definition at line 46 of file ICLTensor.cpp.

47 {
48  this->map(q);
49  std::memset(static_cast<void *>(_mapping), 0, this->info()->total_size());
50  this->unmap(q);
51 }
void map(cl::CommandQueue &q, bool blocking=true)
Enqueue a map operation of the allocated buffer on the given queue.
Definition: ICLTensor.cpp:35
void unmap(cl::CommandQueue &q)
Enqueue an unmap operation of the allocated and mapped buffer on the given queue.
Definition: ICLTensor.cpp:40
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.

References ITensor::info(), ICLTensor::map(), and ICLTensor::unmap().

Referenced by CLCannyEdge::run().

◆ map()

void map ( cl::CommandQueue &  q,
bool  blocking = true 
)

Enqueue a map operation of the allocated buffer on the given queue.

Parameters
[in,out]qThe CL command queue to use for the mapping operation.
[in]blockingIf true, then the mapping will be ready to use by the time this method returns, else it is the caller's responsibility to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer.
Returns
The mapping address.

Definition at line 35 of file ICLTensor.cpp.

36 {
37  _mapping = do_map(q, blocking);
38 }

Referenced by ICLTensor::clear(), CLTensor::map(), CLSubTensor::map(), CLMinMaxLayerKernel::reset(), and CLCropResize::run().

◆ operator=() [1/2]

ICLTensor& operator= ( const ICLTensor )
delete

Prevent instances of this class from being copied.

◆ operator=() [2/2]

ICLTensor& operator= ( ICLTensor &&  )
default

Allow instances of this class to be copied.

◆ quantization()

virtual CLQuantization quantization ( ) const
pure virtual

Interface to be implemented by the child class to return the wrapped quantization info data.

Returns
A wrapped quantization info object.

Implemented in CLSubTensor, and CLTensor.

Referenced by CLSubTensor::quantization().

◆ unmap()

void unmap ( cl::CommandQueue &  q)

Enqueue an unmap operation of the allocated and mapped buffer on the given queue.

Note
This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before the memory is accessed by the device.
Parameters
[in,out]qThe CL command queue to use for the mapping operation.

Definition at line 40 of file ICLTensor.cpp.

41 {
42  do_unmap(q);
43  _mapping = nullptr;
44 }

Referenced by ICLTensor::clear(), CLMinMaxLayerKernel::reset(), CLCropResize::run(), CLTensor::unmap(), and CLSubTensor::unmap().


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