Compute Library
 21.02
CLTensor Class Reference

Basic implementation of the OpenCL tensor interface. More...

#include <CLTensor.h>

Collaboration diagram for CLTensor:
[legend]

Public Member Functions

 CLTensor (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 ~CLTensor ()=default
 Destructor. More...
 
 CLTensor (const CLTensor &)=delete
 Prevent copying by construction. More...
 
 CLTensor (CLTensor &&)=default
 Default move constructor. More...
 
CLTensoroperator= (const CLTensor &)=delete
 Prevent copaingy by assignment. More...
 
CLTensoroperator= (CLTensor &&)=default
 Default move assignment operator. More...
 
CLTensorAllocatorallocator ()
 Return a pointer to the tensor's allocator. More...
 
void map (bool blocking=true)
 Enqueue a map operation of the allocated buffer. More...
 
void unmap ()
 Enqueue an unmap operation of the allocated and mapped buffer. More...
 
TensorInfoinfo () const override
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
TensorInfoinfo () override
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
const cl::Buffer & cl_buffer () const override
 Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the image's data. More...
 
CLQuantization quantization () const override
 Interface to be implemented by the child class to return the wrapped quantization info data. More...
 
void associate_memory_group (IMemoryGroup *memory_group) override
 Associates a memory managable object with the memory group that manages it. More...
 
CLRuntimeContextcontext ()
 
- Public Member Functions inherited from ICLTensor
 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...
 
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 ~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...
 
- Public Member Functions inherited from IMemoryManageable
virtual ~IMemoryManageable ()=default
 Default virtual destructor. More...
 

Detailed Description

Basic implementation of the OpenCL tensor interface.

Definition at line 41 of file CLTensor.h.

Constructor & Destructor Documentation

◆ CLTensor() [1/3]

CLTensor ( IRuntimeContext ctx = nullptr)

Constructor.

Parameters
[in]ctx(Optional) Pointer to a CLRuntimeContext. If nullptr is passed in, the legacy api using the singletons will be used. Otherwise the memory for the tensor will allocate on the context passed in. The singletons legacy api has been deprecated and will be removed in future releases.

Definition at line 31 of file CLTensor.cpp.

32  : _allocator(this, static_cast<CLRuntimeContext *>(ctx)), _ctx(static_cast<CLRuntimeContext *>(ctx))
33 {
34 }

◆ ~CLTensor()

~CLTensor ( )
default

Destructor.

◆ CLTensor() [2/3]

CLTensor ( const CLTensor )
delete

Prevent copying by construction.

◆ CLTensor() [3/3]

CLTensor ( CLTensor &&  )
default

Default move constructor.

Member Function Documentation

◆ allocator()

CLTensorAllocator * allocator ( )

Return a pointer to the tensor's allocator.

Returns
A pointer to the tensor's allocator

Definition at line 61 of file CLTensor.cpp.

Referenced by CLTensorHandle::allocate(), CLQLSTMLayer::CLQLSTMLayer(), CLTensorHandle::CLTensorHandle(), CLReduceMean::configure(), CLMeanStdDev::configure(), CLFFT2D::configure(), CLRNNLayer::configure(), CLFFT1D::configure(), CLHOGGradient::configure(), CLHOGDescriptor::configure(), CLL2NormalizeLayer::configure(), CLArgMinMaxLayer::configure(), CLGaussian5x5::configure(), CLSobel5x5::configure(), CLSobel7x7::configure(), CLFastCorners::configure(), CLSoftmaxLayerGeneric< IS_LOG >::configure(), CLCannyEdge::configure(), CLGEMMLowpMatrixMultiplyCore::configure(), CLWinogradConvolutionLayer::configure(), CLHarrisCorners::configure(), CLFFTConvolutionLayer::configure(), CLGenerateProposalsLayer::configure(), CLHOGMultiDetection::configure(), CLDirectDeconvolutionLayer::configure(), CLGEMMDeconvolutionLayer::configure(), CLLSTMLayerQuantized::configure(), CLConvolutionSquare< matrix_size >::configure(), CLLSTMLayer::configure(), CLQLSTMLayer::configure(), CLGEMMConvolutionLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), CLTensorHandle::free(), CLGEMMLowpMatrixMultiplyCore::prepare(), CLWinogradConvolutionLayer::prepare(), CLGEMMDeconvolutionLayer::prepare(), CLFFTConvolutionLayer::prepare(), CLDirectDeconvolutionLayer::prepare(), CLLSTMLayerQuantized::prepare(), CLGEMM::prepare(), CLFullyConnectedLayer::prepare(), CLQLSTMLayer::prepare(), CLGEMMConvolutionLayer::prepare(), CLGEMMReshapeRHSMatrixKernelManaged::release(), CLTensorHandle::release_if_unused(), CLGEMMReshapeRHSMatrixKernelManaged::run(), CLFFTConvolutionLayer::run(), and arm_compute::test::validation::TEST_CASE().

62 {
63  return &_allocator;
64 }

◆ associate_memory_group()

void associate_memory_group ( IMemoryGroup memory_group)
overridevirtual

Associates a memory managable object with the memory group that manages it.

Parameters
[in]memory_groupMemory group that manages the object.

Implements IMemoryManageable.

Definition at line 86 of file CLTensor.cpp.

References CLTensorAllocator::set_associated_memory_group().

87 {
88  _allocator.set_associated_memory_group(memory_group);
89 }
void set_associated_memory_group(IMemoryGroup *associated_memory_group)
Associates the tensor with a memory group.

◆ cl_buffer()

const cl::Buffer & cl_buffer ( ) const
overridevirtual

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.

Implements ICLTensor.

Definition at line 51 of file CLTensor.cpp.

References CLTensorAllocator::cl_data().

Referenced by CLFastCorners::run(), and CLFFTConvolutionLayer::run().

52 {
53  return _allocator.cl_data();
54 }
const cl::Buffer & cl_data() const
Interface to be implemented by the child class to return the pointer to the CL data.

◆ context()

CLRuntimeContext * context ( )

Definition at line 36 of file CLTensor.cpp.

37 {
38  return _ctx;
39 }

◆ info() [1/2]

◆ info() [2/2]

TensorInfo * info ( )
overridevirtual

Interface to be implemented by the child class to return the tensor's metadata.

Returns
A pointer to the tensor's metadata.

Implements ITensor.

Definition at line 46 of file CLTensor.cpp.

References ITensorAllocator::info().

47 {
48  return &_allocator.info();
49 }
TensorInfo & info()
Return a reference to the tensor&#39;s metadata.

◆ map()

void map ( bool  blocking = true)

Enqueue a map operation of the allocated buffer.

Parameters
[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.

Definition at line 66 of file CLTensor.cpp.

References CLScheduler::get(), CLRuntimeContext::gpu_scheduler(), ICLTensor::map(), and CLScheduler::queue().

Referenced by CLAccessor::CLAccessor(), CLMeanStdDev::configure(), CLFFT1D::configure(), CLGEMMLowpMatrixMultiplyCore::configure(), CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), CLTensorHandle::map(), CLQLSTMLayer::prepare(), CLHarrisCorners::run(), arm_compute::utils::unmap(), and CLGenerateProposalsLayer::validate().

67 {
68  ICLTensor::map(_ctx == nullptr ? CLScheduler::get().queue() : _ctx->gpu_scheduler()->queue(), blocking);
69 }
void map(cl::CommandQueue &q, bool blocking=true)
Enqueue a map operation of the allocated buffer on the given queue.
Definition: ICLTensor.cpp:35
static CLScheduler & get()
Access the scheduler singleton.
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Definition: CLScheduler.cpp:41

◆ operator=() [1/2]

CLTensor& operator= ( const CLTensor )
delete

Prevent copaingy by assignment.

◆ operator=() [2/2]

CLTensor& operator= ( CLTensor &&  )
default

Default move assignment operator.

◆ quantization()

CLQuantization quantization ( ) const
overridevirtual

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

Returns
A wrapped quantization info object.

Implements ICLTensor.

Definition at line 56 of file CLTensor.cpp.

References CLTensorAllocator::quantization().

Referenced by arm_compute::test::validation::TEST_CASE().

57 {
58  return _allocator.quantization();
59 }
CLQuantization quantization() const
Wrapped quantization info data accessor.

◆ unmap()

void unmap ( )

Enqueue an unmap operation of the allocated and mapped buffer.

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.

Definition at line 71 of file CLTensor.cpp.

References ICLTensor::buffer(), CLScheduler::get(), CLRuntimeContext::gpu_scheduler(), CLTensorAllocator::map(), CLScheduler::queue(), ICLTensor::unmap(), and CLTensorAllocator::unmap().

Referenced by CLMeanStdDev::configure(), CLFFT1D::configure(), CLGEMMLowpMatrixMultiplyCore::configure(), CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), CLQLSTMLayer::prepare(), CLHarrisCorners::run(), CLTensorHandle::unmap(), arm_compute::utils::unmap(), CLGenerateProposalsLayer::validate(), and CLAccessor::~CLAccessor().

72 {
73  ICLTensor::unmap(_ctx == nullptr ? CLScheduler::get().queue() : _ctx->gpu_scheduler()->queue());
74 }
static CLScheduler & get()
Access the scheduler singleton.
void unmap(cl::CommandQueue &q)
Enqueue an unmap operation of the allocated and mapped buffer on the given queue. ...
Definition: ICLTensor.cpp:40
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Definition: CLScheduler.cpp:41

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