Compute Library
 19.08
Memory Class Reference

CPU implementation of memory object. More...

#include <Memory.h>

Collaboration diagram for Memory:
[legend]

Public Member Functions

 Memory ()
 Default Constructor. More...
 
 Memory (const std::shared_ptr< IMemoryRegion > &memory)
 Default Constructor. More...
 
 Memory (IMemoryRegion *memory)
 Default Constructor. More...
 
 Memory (const Memory &)=default
 Allow instances of this class to be copied. More...
 
Memoryoperator= (const Memory &)=default
 Allow instances of this class to be copy assigned. More...
 
 Memory (Memory &&) noexcept=default
 Allow instances of this class to be moved. More...
 
Memoryoperator= (Memory &&) noexcept=default
 Allow instances of this class to be move assigned. More...
 
IMemoryRegionregion () final
 Region accessor. More...
 
IMemoryRegionregion () const final
 Region accessor. More...
 
void set_region (IMemoryRegion *region) final
 Sets a memory region. More...
 
void set_owned_region (std::unique_ptr< IMemoryRegion > region) final
 Sets a memory region. More...
 
- Public Member Functions inherited from IMemory
virtual ~IMemory ()=default
 Virtual default destructor. More...
 

Detailed Description

CPU implementation of memory object.

Definition at line 37 of file Memory.h.

Constructor & Destructor Documentation

◆ Memory() [1/5]

Memory ( )

Default Constructor.

Definition at line 30 of file Memory.cpp.

31  : _region(nullptr), _region_owned(nullptr)
32 {
33 }

◆ Memory() [2/5]

Memory ( const std::shared_ptr< IMemoryRegion > &  memory)

Default Constructor.

Parameters
[in]memoryMemory to be imported

Definition at line 35 of file Memory.cpp.

36  : _region(nullptr), _region_owned(memory)
37 {
38  _region_owned = memory;
39  _region = _region_owned.get();
40 }

◆ Memory() [3/5]

Memory ( IMemoryRegion memory)

Default Constructor.

Note
Ownership of the memory is not transferred to this object. Thus management (allocate/free) should be done by the client.
Parameters
[in]memoryMemory to be imported

Definition at line 42 of file Memory.cpp.

43  : _region(memory), _region_owned(nullptr)
44 {
45  _region = memory;
46 }

◆ Memory() [4/5]

Memory ( const Memory )
default

Allow instances of this class to be copied.

◆ Memory() [5/5]

Memory ( Memory &&  )
defaultnoexcept

Allow instances of this class to be moved.

Member Function Documentation

◆ operator=() [1/2]

Memory& operator= ( const Memory )
default

Allow instances of this class to be copy assigned.

◆ operator=() [2/2]

Memory& operator= ( Memory &&  )
defaultnoexcept

Allow instances of this class to be move assigned.

◆ region() [1/2]

IMemoryRegion * region ( )
finalvirtual

Region accessor.

Returns
Memory region

Implements IMemory.

Definition at line 48 of file Memory.cpp.

49 {
50  return _region;
51 }

Referenced by TensorAllocator::data(), TensorAllocator::set_associated_memory_group(), Memory::set_owned_region(), and Memory::set_region().

◆ region() [2/2]

IMemoryRegion * region ( ) const
finalvirtual

Region accessor.

Returns
Memory region

Implements IMemory.

Definition at line 53 of file Memory.cpp.

54 {
55  return _region;
56 }

◆ set_owned_region()

void set_owned_region ( std::unique_ptr< IMemoryRegion region)
finalvirtual

Sets a memory region.

Warning
Ownership of the memory region is transfered along
Parameters
regionMemory region

Implements IMemory.

Definition at line 64 of file Memory.cpp.

65 {
66  _region_owned = std::move(region);
67  _region = _region_owned.get();
68 }
IMemoryRegion * region() final
Region accessor.
Definition: Memory.cpp:48

References Memory::region().

Referenced by TensorAllocator::allocate(), and TensorAllocator::import_memory().

◆ set_region()

void set_region ( IMemoryRegion region)
finalvirtual

Sets a memory region.

Warning
Ownership of the memory region remains to the caller
Parameters
regionMemory region

Implements IMemory.

Definition at line 58 of file Memory.cpp.

59 {
60  _region_owned = nullptr;
61  _region = region;
62 }
IMemoryRegion * region() final
Region accessor.
Definition: Memory.cpp:48

References Memory::region().

Referenced by TensorAllocator::free().


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