Compute Library
 19.08
CLTensor Class Reference

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

#include <CLTensor.h>

Collaboration diagram for CLTensor:
[legend]

Public Member Functions

 CLTensor ()
 Constructor. 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 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...
 
- 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...
 

Detailed Description

Basic implementation of the OpenCL tensor interface.

Definition at line 40 of file CLTensor.h.

Constructor & Destructor Documentation

◆ CLTensor()

CLTensor ( )

Constructor.

Definition at line 30 of file CLTensor.cpp.

31  : _allocator(this)
32 {
33 }

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 55 of file CLTensor.cpp.

56 {
57  return &_allocator;
58 }

Referenced by CLTensorHandle::allocate(), CLTensorHandle::CLTensorHandle(), CLRNNLayer::configure(), CLFFT2D::configure(), CLFFT1D::configure(), CLMeanStdDev::configure(), CLL2NormalizeLayer::configure(), CLHOGDescriptor::configure(), CLHOGGradient::configure(), CLGaussian5x5::configure(), CLSoftmaxLayer::configure(), CLSobel5x5::configure(), CLSobel7x7::configure(), CLCannyEdge::configure(), CLFastCorners::configure(), CLLocallyConnectedLayer::configure(), CLWinogradConvolutionLayer::configure(), CLDepthwiseConvolutionLayer3x3::configure(), CLHarrisCorners::configure(), CLHOGMultiDetection::configure(), CLGEMMLowpMatrixMultiplyCore::configure(), CLFFTConvolutionLayer::configure(), CLGenerateProposalsLayer::configure(), CLLSTMLayerQuantized::configure(), CLLSTMLayer::configure(), CLDirectDeconvolutionLayer::configure(), CLGEMMDeconvolutionLayer::configure(), CLFullyConnectedLayer::configure(), CLGEMMConvolutionLayer::configure(), CLDepthwiseConvolutionLayer::configure(), CLTensorHandle::free(), arm_compute::utils::init_sgemm_output(), CLLocallyConnectedLayer::prepare(), CLGEMMLowpMatrixMultiplyCore::prepare(), CLWinogradConvolutionLayer::prepare(), CLDepthwiseConvolutionLayer3x3::prepare(), CLGEMM::prepare(), CLFFTConvolutionLayer::prepare(), CLGEMMDeconvolutionLayer::prepare(), CLDirectDeconvolutionLayer::prepare(), CLFullyConnectedLayer::prepare(), CLLSTMLayerQuantized::prepare(), CLGEMMConvolutionLayer::prepare(), CLDepthwiseConvolutionLayer::prepare(), CLTensorHandle::release_if_unused(), CLFFTConvolutionLayer::run(), and arm_compute::test::validation::TEST_CASE().

◆ 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 45 of file CLTensor.cpp.

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

References CLTensorAllocator::cl_data().

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

◆ info() [1/2]

TensorInfo * info ( ) const
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 35 of file CLTensor.cpp.

36 {
37  return &_allocator.info();
38 }
TensorInfo & info()
Return a reference to the tensor's metadata.

References ITensorAllocator::info().

Referenced by CLDepthwiseConvolutionLayer3x3NCHWKernel::configure(), CLDepthwiseConvolutionLayer3x3NHWCKernel::configure(), CLRNNLayer::configure(), CLDeconvolutionLayer::configure(), GCDepthwiseConvolutionLayer3x3Kernel::configure(), GCConvolutionLayerReshapeWeights::configure(), NEConvolutionLayerReshapeWeights::configure(), GCDirectConvolutionLayerKernel< kernel_size >::configure(), NERNNLayer::configure(), NEDepthwiseConvolutionLayer3x3Kernel::configure(), NEDepthwiseConvolutionLayerNativeKernel::configure(), CLDirectConvolutionLayerOutputStageKernel::configure(), CLConvolutionLayerReshapeWeights::configure(), NEDirectConvolutionLayerOutputStageKernel::configure(), CLGEMMLowpOffsetContributionOutputStageKernel::configure(), CLWinogradOutputTransformKernel::configure(), NEDirectConvolutionLayerKernel::configure(), GCDirectConvolutionLayer::configure(), NEDepthwiseConvolutionAssemblyDispatch::configure(), CLDeconvolutionReshapeOutputKernel::configure(), CLDirectConvolutionLayerKernel::configure(), CLGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel::configure(), CLGEMMLowpQuantizeDownInt32ToUint8ScaleByFloatKernel::configure(), CLGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointKernel::configure(), CLGEMMLowpQuantizeDownInt32ToUint8ScaleKernel::configure(), CLGEMMLowpOffsetContributionKernel::configure(), NEWinogradConvolutionLayer::configure(), NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel::configure(), NELocallyConnectedLayer::configure(), CLLocallyConnectedLayer::configure(), CLWinogradConvolutionLayer::configure(), NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointKernel::configure(), NEGEMMLowpQuantizeDownInt32ToUint8ScaleKernel::configure(), CLLaplacianReconstruct::configure(), CLDepthwiseConvolutionLayer3x3::configure(), NEDepthwiseConvolutionLayer3x3::configure(), GCFullyConnectedLayer::configure(), NEWeightsReshapeKernel::configure(), NEFFTConvolutionLayer::configure(), CLFFTConvolutionLayer::configure(), CLGenerateProposalsLayer::configure(), CLGaussianPyramidHalf::configure(), NEGEMMLowpOffsetContributionOutputStageKernel::configure(), CLConvolutionLayer::configure(), CLLSTMLayerQuantized::configure(), CLLSTMLayer::configure(), NEConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), CLGEMMDeconvolutionLayer::configure(), NEDeconvolutionLayer::configure(), NEFullyConnectedLayer::configure(), CLFullyConnectedLayer::configure(), GCConvolutionLayer::configure(), CLGaussianPyramidOrb::configure(), NEGEMMConvolutionLayer::configure(), CLGEMMConvolutionLayer::configure(), CLDepthwiseConvolutionLayer::configure(), NEDepthwiseConvolutionLayerOptimized::configure(), NEDepthwiseConvolutionLayer::configure(), arm_compute::graph::backends::detail::create_convolution_layer(), arm_compute::graph::backends::detail::create_convolution_layer< GCConvolutionLayerFunctions, GCTargetInfo >(), arm_compute::graph::backends::detail::create_convolution_layer< NEConvolutionLayerFunctions, NETargetInfo >(), arm_compute::graph::backends::detail::create_deconvolution_layer(), arm_compute::graph::backends::detail::create_depthwise_convolution_layer(), arm_compute::graph::backends::detail::create_depthwise_convolution_layer< GCDepthwiseConvolutionLayerFunctions, GCTargetInfo >(), arm_compute::graph::backends::detail::create_fully_connected_layer(), arm_compute::graph::backends::detail::create_fused_convolution_batch_normalization_layer(), arm_compute::graph::backends::detail::create_fused_depthwise_convolution_batch_normalization_layer(), CLAccessor::data_layout(), arm_compute::test::validation::DATA_TEST_CASE(), CLAccessor::data_type(), CLAccessor::element_size(), CLAccessor::format(), arm_compute::test::validation::if(), CLAccessor::num_channels(), CLAccessor::num_elements(), CLAccessor::padding(), CLAccessor::quantization_info(), CLFastCorners::run(), CLAccessor::shape(), CLAccessor::size(), and arm_compute::test::validation::TEST_CASE().

◆ 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 40 of file CLTensor.cpp.

41 {
42  return &_allocator.info();
43 }
TensorInfo & info()
Return a reference to the tensor's metadata.

References ITensorAllocator::info().

◆ map() [1/2]

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 60 of file CLTensor.cpp.

61 {
62  ICLTensor::map(CLScheduler::get().queue(), blocking);
63 }
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.
Definition: CLScheduler.cpp:41

References CLScheduler::get(), and ICLTensor::map().

Referenced by CLFFT1D::configure(), CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), CLTensorHandle::map(), and CLHarrisCorners::run().

◆ map() [2/2]

void map

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 }

◆ 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 50 of file CLTensor.cpp.

51 {
52  return _allocator.quantization();
53 }
CLQuantization quantization() const
Wrapped quantization info data accessor.

References CLTensorAllocator::quantization().

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

◆ unmap() [1/2]

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 65 of file CLTensor.cpp.

66 {
68 }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
void unmap(cl::CommandQueue &q)
Enqueue an unmap operation of the allocated and mapped buffer on the given queue.
Definition: ICLTensor.cpp:40

References CLScheduler::get(), and ICLTensor::unmap().

Referenced by CLFFT1D::configure(), CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), CLHarrisCorners::run(), CLTensorHandle::unmap(), and CLAccessor::~CLAccessor().

◆ unmap() [2/2]

void unmap

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 }

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