Compute Library
 19.08
MemoryGroupBase< TensorType > Class Template Reference

Memory group. More...

#include <CLTensorAllocator.h>

Collaboration diagram for MemoryGroupBase< TensorType >:
[legend]

Public Member Functions

 MemoryGroupBase (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default Constructor. More...
 
 ~MemoryGroupBase ()=default
 Default destructor. More...
 
 MemoryGroupBase (const MemoryGroupBase &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
MemoryGroupBaseoperator= (const MemoryGroupBase &)=delete
 Prevent instances of this class from being copy assigned (As this class contains pointers) More...
 
 MemoryGroupBase (MemoryGroupBase &&)=default
 Allow instances of this class to be moved. More...
 
MemoryGroupBaseoperator= (MemoryGroupBase &&)=default
 Allow instances of this class to be moved. More...
 
void manage (TensorType *obj)
 Sets a object to be managed by the given memory group. More...
 
void finalize_memory (TensorType *obj, IMemory &obj_memory, size_t size, size_t alignment=0)
 Finalizes memory for a given object. More...
 
void acquire () override
 Acquires backing memory for the whole group. More...
 
void release () override
 Releases backing memory of the whole group. More...
 
MemoryMappingsmappings () override
 Gets the memory mapping of the group. More...
 
- Public Member Functions inherited from IMemoryGroup
virtual ~IMemoryGroup ()=default
 Default virtual destructor. More...
 

Detailed Description

template<typename TensorType>
class arm_compute::MemoryGroupBase< TensorType >

Memory group.

Definition at line 40 of file CLTensorAllocator.h.

Constructor & Destructor Documentation

◆ MemoryGroupBase() [1/3]

MemoryGroupBase ( std::shared_ptr< IMemoryManager memory_manager = nullptr)
inline

Default Constructor.

Definition at line 92 of file MemoryGroupBase.h.

93  : _memory_manager(std::move(memory_manager)), _pool(nullptr), _mappings()
94 {
95  if(_memory_manager)
96  {
97  ARM_COMPUTE_ERROR_ON(!_memory_manager->lifetime_manager());
98  }
99 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337

◆ ~MemoryGroupBase()

~MemoryGroupBase ( )
default

Default destructor.

◆ MemoryGroupBase() [2/3]

MemoryGroupBase ( const MemoryGroupBase< TensorType > &  )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ MemoryGroupBase() [3/3]

MemoryGroupBase ( MemoryGroupBase< TensorType > &&  )
default

Allow instances of this class to be moved.

Member Function Documentation

◆ acquire()

void acquire ( )
inlineoverridevirtual

Acquires backing memory for the whole group.

Implements IMemoryGroup.

Definition at line 134 of file MemoryGroupBase.h.

135 {
136  if(!_mappings.empty())
137  {
138  ARM_COMPUTE_ERROR_ON(!_memory_manager->pool_manager());
139  _pool = _memory_manager->pool_manager()->lock_pool();
140  _pool->acquire(_mappings);
141  }
142 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337

Referenced by NEFFT2D::run().

◆ finalize_memory()

void finalize_memory ( TensorType *  obj,
IMemory obj_memory,
size_t  size,
size_t  alignment = 0 
)
inline

Finalizes memory for a given object.

Note
Manager must not be finalized
Parameters
[in,out]objObject to request memory for
[in,out]obj_memoryObject's memory handling interface which can be used to alter the underlying memory that is used by the object.
[in]sizeSize of memory to allocate
[in]alignment(Optional) Alignment to use

Definition at line 120 of file MemoryGroupBase.h.

121 {
122  // TODO (geopin01) : Check size (track size in MemoryMappings)
123  // Check if existing mapping is valid
124  ARM_COMPUTE_ERROR_ON(!_mappings.empty() && (_mappings.find(&obj_memory) == std::end(_mappings)));
125 
126  if(_memory_manager && _mappings.empty())
127  {
128  ARM_COMPUTE_ERROR_ON(!_memory_manager->lifetime_manager());
129  _memory_manager->lifetime_manager()->end_lifetime(obj, obj_memory, size, alignment);
130  }
131 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337

Referenced by TensorAllocator::allocate(), GCTensorAllocator::allocate(), and CLTensorAllocator::allocate().

◆ manage()

void manage ( TensorType *  obj)
inline

Sets a object to be managed by the given memory group.

Note
Manager must not be finalized
Parameters
[in]objObject to be managed

Definition at line 102 of file MemoryGroupBase.h.

103 {
104  if(_memory_manager && _mappings.empty())
105  {
106  ARM_COMPUTE_ERROR_ON(!_memory_manager->lifetime_manager());
107 
108  // Defer registration to the first managed object
109  _memory_manager->lifetime_manager()->register_group(this);
110 
111  // Associate this memory group with the tensor
112  associate_memory_group(obj);
113 
114  // Start object lifetime
115  _memory_manager->lifetime_manager()->start_lifetime(obj);
116  }
117 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337

Referenced by CLReduceMean::configure(), NEGEMMLowpAssemblyMatrixMultiplyCore::configure(), CLRNNLayer::configure(), NEReduceMean::configure(), CLFFT2D::configure(), NEFFT2D::configure(), CLFFT1D::configure(), NEL2NormalizeLayer::configure(), CLMeanStdDev::configure(), NEFFT1D::configure(), GCNormalizationLayer::configure(), NEHOGDescriptor::configure(), CLL2NormalizeLayer::configure(), CLReductionOperation::configure(), CLHOGDescriptor::configure(), GCSoftmaxLayer::configure(), NEGaussian5x5::configure(), NEHOGGradient::configure(), NENormalizationLayer::configure(), CLHOGGradient::configure(), CLGaussian5x5::configure(), NERNNLayer::configure(), NESobel7x7::configure(), CLSoftmaxLayer::configure(), NESobel5x5::configure(), NEFastCorners::configure(), CLSobel5x5::configure(), CLSobel7x7::configure(), NEDepthwiseConvolutionAssemblyDispatch::configure(), CPPDetectionPostProcessLayer::configure(), CLCannyEdge::configure(), CLFastCorners::configure(), NEWinogradConvolutionLayer::configure(), NESoftmaxLayer::configure(), CLLocallyConnectedLayer::configure(), NELocallyConnectedLayer::configure(), CLWinogradConvolutionLayer::configure(), NEGEMM::configure(), GCGEMM::configure(), NECannyEdge::configure(), CLDepthwiseConvolutionLayer3x3::configure(), NEOpticalFlow::configure(), CLHarrisCorners::configure(), NEHarrisCorners::configure(), CLHOGMultiDetection::configure(), CLGEMMLowpMatrixMultiplyCore::configure(), NEHOGMultiDetection::configure(), NEFFTConvolutionLayer::configure(), CLFFTConvolutionLayer::configure(), NEGEMMLowpMatrixMultiplyCore::configure(), NELSTMLayer::configure(), CLGenerateProposalsLayer::configure(), CLOpticalFlow::configure(), CLLSTMLayerQuantized::configure(), NELSTMLayerQuantized::configure(), CLLSTMLayer::configure(), CLDirectDeconvolutionLayer::configure(), CLGEMMDeconvolutionLayer::configure(), NEDeconvolutionLayer::configure(), GCConvolutionLayer::configure(), NEGEMMInterleavedWrapper::configure(), NEGEMMConvolutionLayer::configure(), and CLGEMMConvolutionLayer::configure().

◆ mappings()

MemoryMappings & mappings ( )
inlineoverridevirtual

Gets the memory mapping of the group.

Implements IMemoryGroup.

Definition at line 158 of file MemoryGroupBase.h.

159 {
160  return _mappings;
161 }

◆ operator=() [1/2]

MemoryGroupBase& operator= ( const MemoryGroupBase< TensorType > &  )
delete

Prevent instances of this class from being copy assigned (As this class contains pointers)

◆ operator=() [2/2]

MemoryGroupBase& operator= ( MemoryGroupBase< TensorType > &&  )
default

Allow instances of this class to be moved.

◆ release()

void release ( )
inlineoverridevirtual

Releases backing memory of the whole group.

Implements IMemoryGroup.

Definition at line 145 of file MemoryGroupBase.h.

146 {
147  if(_pool != nullptr)
148  {
149  ARM_COMPUTE_ERROR_ON(!_memory_manager->pool_manager());
150  ARM_COMPUTE_ERROR_ON(_mappings.empty());
151  _pool->release(_mappings);
152  _memory_manager->pool_manager()->unlock_pool(_pool);
153  _pool = nullptr;
154  }
155 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
virtual void release(MemoryMappings &handles)=0
Releases a memory block.

Referenced by NEFFT2D::run().


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