23.11
|
Basic implementation of a CL memory tensor allocator. More...
#include <CLTensorAllocator.h>
Public Member Functions | |
CLTensorAllocator (IMemoryManageable *owner=nullptr, CLRuntimeContext *ctx=nullptr) | |
Default constructor. More... | |
CLTensorAllocator (const CLTensorAllocator &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
CLTensorAllocator & | operator= (const CLTensorAllocator &)=delete |
Prevent instances of this class from being copy assigned (As this class contains pointers) More... | |
CLTensorAllocator (CLTensorAllocator &&)=default | |
Allow instances of this class to be moved. More... | |
CLTensorAllocator & | operator= (CLTensorAllocator &&)=default |
Allow instances of this class to be moved. More... | |
uint8_t * | data () |
Interface to be implemented by the child class to return the pointer to the mapped data. More... | |
const cl::Buffer & | cl_data () const |
Interface to be implemented by the child class to return the pointer to the CL data. More... | |
CLQuantization | quantization () const |
Wrapped quantization info data accessor. More... | |
uint8_t * | map (cl::CommandQueue &q, bool blocking) |
Enqueue a map operation of the allocated buffer on the given queue. More... | |
void | unmap (cl::CommandQueue &q, uint8_t *mapping) |
Enqueue an unmap operation of the allocated buffer on the given queue. More... | |
void | allocate () override |
Allocate size specified by TensorInfo of OpenCL memory. More... | |
void | free () override |
Free allocated OpenCL memory. More... | |
Status | import_memory (cl::Buffer buffer) |
Import an existing memory as a tensor's backing memory. More... | |
void | set_associated_memory_group (IMemoryGroup *associated_memory_group) |
Associates the tensor with a memory group. More... | |
![]() | |
ITensorAllocator ()=default | |
Default constructor. More... | |
ITensorAllocator (const ITensorAllocator &)=default | |
Allow instances of this class to be copy constructed. More... | |
ITensorAllocator & | operator= (const ITensorAllocator &)=default |
Allow instances of this class to be copied. More... | |
ITensorAllocator (ITensorAllocator &&)=default | |
Allow instances of this class to be move constructed. More... | |
ITensorAllocator & | operator= (ITensorAllocator &&)=default |
Allow instances of this class to be moved. More... | |
virtual | ~ITensorAllocator ()=default |
Default virtual destructor. More... | |
void | init (const TensorInfo &input, size_t alignment=0) |
Initialize a tensor based on the passed TensorInfo. More... | |
void | soft_init (TensorInfo &input, size_t alignment=0) |
Initialize a tensor based with a reference TensorInfo. More... | |
TensorInfo & | info () |
Return a reference to the tensor's metadata. More... | |
const TensorInfo & | info () const |
Return a constant reference to the tensor's metadata. More... | |
size_t | alignment () const |
Return underlying's tensor buffer alignment. More... | |
Static Public Member Functions | |
static void | set_global_allocator (IAllocator *allocator) |
Sets global allocator that will be used by all CLTensor objects. More... | |
Basic implementation of a CL memory tensor allocator.
Definition at line 42 of file CLTensorAllocator.h.
CLTensorAllocator | ( | IMemoryManageable * | owner = nullptr , |
CLRuntimeContext * | ctx = nullptr |
||
) |
Default constructor.
[in] | owner | (Optional) Owner of the allocator. |
[in] | ctx | (Optional) Runtime context. |
Definition at line 111 of file CLTensorAllocator.cpp.
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
default |
Allow instances of this class to be moved.
|
overridevirtual |
Allocate size specified by TensorInfo of OpenCL memory.
Implements ITensorAllocator.
Definition at line 131 of file CLTensorAllocator.cpp.
References ITensorAllocator::alignment(), arm_compute::test::validation::data_type, IMemoryGroup::finalize_memory(), ITensorAllocator::info(), arm_compute::is_data_type_quantized_per_channel(), TensorInfo::set_is_resizable(), and CLMemory::set_owned_region().
Referenced by CLTensorHandle::allocate(), CLAuxTensorHandler::CLAuxTensorHandler(), arm_compute::test::validation::compute_float_target_in_place(), CLReduceMean::configure(), CLFFT2D::configure(), CLFFT1D::configure(), CLRNNLayer::configure(), CLDepthwiseConvolutionLayer::configure(), CLL2NormalizeLayer::configure(), CLArgMinMaxLayer::configure(), CLReductionOperation::configure(), CLInstanceNormalizationLayer::configure(), CLFFTConvolutionLayer::configure(), CLGenerateProposalsLayer::configure(), CLGEMMDeconvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), CLLSTMLayerQuantized::configure(), CLLSTMLayer::configure(), CLQLSTMLayer::configure(), arm_compute::manage_workspace(), CLDepthwiseConvolutionLayer::prepare(), CLGEMMDeconvolutionLayer::prepare(), CLFFTConvolutionLayer::prepare(), CLDirectDeconvolutionLayer::prepare(), CLLSTMLayerQuantized::prepare(), CLQLSTMLayer::prepare(), CLConvertFullyConnectedWeightsManaged::run(), and arm_compute::test::validation::TEST_CASE().
const cl::Buffer & cl_data | ( | ) | const |
Interface to be implemented by the child class to return the pointer to the CL data.
Definition at line 126 of file CLTensorAllocator.cpp.
References ICLMemoryRegion::cl_data(), CLMemory::cl_region(), and CLMemory::region().
Referenced by CLTensor::cl_buffer().
uint8_t * data | ( | ) |
Interface to be implemented by the child class to return the pointer to the mapped data.
Definition at line 121 of file CLTensorAllocator.cpp.
|
overridevirtual |
Free allocated OpenCL memory.
Implements ITensorAllocator.
Definition at line 163 of file CLTensorAllocator.cpp.
References ITensorAllocator::info(), TensorInfo::set_is_resizable(), and CLMemory::set_region().
Referenced by CLTensorHandle::free(), CLFFTConvolutionLayer::prepare(), CLGEMMDeconvolutionLayer::prepare(), CLDirectDeconvolutionLayer::prepare(), CLLSTMLayerQuantized::prepare(), CLConvertFullyConnectedWeightsManaged::release(), CLTensorHandle::release_if_unused(), and arm_compute::test::validation::TEST_CASE().
Status import_memory | ( | cl::Buffer | buffer | ) |
Import an existing memory as a tensor's backing memory.
[in] | buffer | Buffer to be used as backing memory |
Definition at line 171 of file CLTensorAllocator.cpp.
References ARM_COMPUTE_RETURN_ERROR_ON, CLScheduler::context(), CLScheduler::get(), ITensorAllocator::info(), TensorInfo::set_is_resizable(), and CLMemory::set_owned_region().
Referenced by CLAuxTensorHandler::CLAuxTensorHandler(), CLFFTConvolutionLayer::run(), and arm_compute::test::validation::TEST_CASE().
uint8_t * map | ( | cl::CommandQueue & | q, |
bool | blocking | ||
) |
Enqueue a map operation of the allocated buffer on the given queue.
[in,out] | q | The CL command queue to use for the mapping operation. |
[in] | blocking | If 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. |
Definition at line 224 of file CLTensorAllocator.cpp.
References ARM_COMPUTE_ERROR_ON, IMemoryRegion::buffer(), CLMemory::cl_region(), ICLMemoryRegion::map(), and CLMemory::region().
|
default |
Allow instances of this class to be moved.
|
delete |
Prevent instances of this class from being copy assigned (As this class contains pointers)
CLQuantization quantization | ( | ) | const |
Wrapped quantization info data accessor.
Definition at line 116 of file CLTensorAllocator.cpp.
Referenced by CLTensor::quantization().
void set_associated_memory_group | ( | IMemoryGroup * | associated_memory_group | ) |
Associates the tensor with a memory group.
[in] | associated_memory_group | Memory group to associate the tensor with |
Definition at line 184 of file CLTensorAllocator.cpp.
References ARM_COMPUTE_ERROR_ON, ICLMemoryRegion::cl_data(), CLMemory::cl_region(), and CLMemory::region().
Referenced by CLTensor::associate_memory_group(), and arm_compute::test::validation::TEST_CASE().
|
static |
Sets global allocator that will be used by all CLTensor objects.
[in] | allocator | Allocator to be used as a global allocator |
Definition at line 193 of file CLTensorAllocator.cpp.
References arm_compute::test::validation::allocator().
Referenced by arm_compute::test::validation::TEST_CASE().
void unmap | ( | cl::CommandQueue & | q, |
uint8_t * | mapping | ||
) |
Enqueue an unmap operation of the allocated buffer on the given queue.
[in,out] | q | The CL command queue to use for the mapping operation. |
[in] | mapping | The cpu mapping to unmap. |
Definition at line 234 of file CLTensorAllocator.cpp.
References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, IMemoryRegion::buffer(), CLMemory::cl_region(), CLMemory::region(), and ICLMemoryRegion::unmap().