Compute Library
 20.08
MemoryGroup Class Referencefinal

Memory group. More...

#include <MemoryGroup.h>

Collaboration diagram for MemoryGroup:
[legend]

Public Member Functions

 MemoryGroup (std::shared_ptr< IMemoryManager >=nullptr) noexcept
 Default Constructor. More...
 
 ~MemoryGroup ()=default
 Default destructor. More...
 
 MemoryGroup (const MemoryGroup &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
MemoryGroupoperator= (const MemoryGroup &)=delete
 Prevent instances of this class from being copy assigned (As this class contains pointers) More...
 
 MemoryGroup (MemoryGroup &&)=default
 Allow instances of this class to be moved. More...
 
MemoryGroupoperator= (MemoryGroup &&)=default
 Allow instances of this class to be moved. More...
 
void manage (IMemoryManageable *obj) override
 Sets a object to be managed by the given memory group. More...
 
void finalize_memory (IMemoryManageable *obj, IMemory &obj_memory, size_t size, size_t alignment) override
 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

Memory group.

Definition at line 43 of file MemoryGroup.h.

Constructor & Destructor Documentation

◆ MemoryGroup() [1/3]

MemoryGroup ( std::shared_ptr< IMemoryManager memory_manager = nullptr)
inlinenoexcept

Default Constructor.

Definition at line 72 of file MemoryGroup.h.

73  : _memory_manager(memory_manager),
74  _pool(nullptr),
75  _mappings()
76 {
77 }

◆ ~MemoryGroup()

~MemoryGroup ( )
default

Default destructor.

◆ MemoryGroup() [2/3]

MemoryGroup ( const MemoryGroup )
delete

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

◆ MemoryGroup() [3/3]

MemoryGroup ( MemoryGroup &&  )
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 105 of file MemoryGroup.h.

106 {
107  if(!_mappings.empty())
108  {
109  ARM_COMPUTE_ERROR_ON(!_memory_manager->pool_manager());
110  _pool = _memory_manager->pool_manager()->lock_pool();
111  _pool->acquire(_mappings);
112  }
113 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

References ARM_COMPUTE_ERROR_ON.

Referenced by NEFFT2D::run().

◆ finalize_memory()

void finalize_memory ( IMemoryManageable obj,
IMemory obj_memory,
size_t  size,
size_t  alignment 
)
inlineoverridevirtual

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

Implements IMemoryGroup.

Definition at line 96 of file MemoryGroup.h.

97 {
98  if(_memory_manager)
99  {
100  ARM_COMPUTE_ERROR_ON(!_memory_manager->lifetime_manager());
101  _memory_manager->lifetime_manager()->end_lifetime(obj, obj_memory, size, alignment);
102  }
103 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

References ARM_COMPUTE_ERROR_ON.

◆ manage()

void manage ( IMemoryManageable obj)
inlineoverridevirtual

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

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

Implements IMemoryGroup.

Definition at line 79 of file MemoryGroup.h.

80 {
81  if(_memory_manager && (obj != nullptr))
82  {
83  ARM_COMPUTE_ERROR_ON(!_memory_manager->lifetime_manager());
84 
85  // Defer registration to the first managed object
86  _memory_manager->lifetime_manager()->register_group(this);
87 
88  // Associate this memory group with the tensor
89  obj->associate_memory_group(this);
90 
91  // Start object lifetime
92  _memory_manager->lifetime_manager()->start_lifetime(obj);
93  }
94 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

References ARM_COMPUTE_ERROR_ON, and IMemoryManageable::associate_memory_group().

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

◆ mappings()

MemoryMappings & mappings ( )
inlineoverridevirtual

Gets the memory mapping of the group.

Implements IMemoryGroup.

Definition at line 127 of file MemoryGroup.h.

128 {
129  return _mappings;
130 }

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

◆ operator=() [1/2]

MemoryGroup& operator= ( const MemoryGroup )
delete

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

◆ operator=() [2/2]

MemoryGroup& operator= ( MemoryGroup &&  )
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 115 of file MemoryGroup.h.

116 {
117  if(_pool != nullptr)
118  {
119  ARM_COMPUTE_ERROR_ON(!_memory_manager->pool_manager());
120  ARM_COMPUTE_ERROR_ON(_mappings.empty());
121  _pool->release(_mappings);
122  _memory_manager->pool_manager()->unlock_pool(_pool);
123  _pool = nullptr;
124  }
125 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
virtual void release(MemoryMappings &handles)=0
Releases a memory block.

References ARM_COMPUTE_ERROR_ON, and IMemoryPool::release().

Referenced by NEFFT2D::run().


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