#include <memory_manager.h>
|
| | Allocator (AllocatorType type) |
| |
| virtual | ~Allocator ()=default |
| |
| Tensor | Empty (ffi::Shape shape, DLDataType dtype, Device dev, ffi::Optional< ffi::String > mem_scope=std::nullopt) |
| | Allocate an empty Tensor using from the allocator. More...
|
| |
| AllocatorType | type () const |
| | Return the allocator type. More...
|
| |
| virtual Buffer | Alloc (Device dev, size_t nbytes, size_t alignment, DLDataType type_hint)=0 |
| | Allocate a buffer given a size, alignment and type. More...
|
| |
| virtual Buffer | Alloc (Device dev, ffi::Shape shape, DLDataType type_hint, const std::string &mem_scope="") |
| | Allocate a buffer given a shape and type. More...
|
| |
| virtual void * | CreateView (const Buffer &buffer, ffi::Shape shape, DLDataType type_hint, const std::string &mem_scope="global") |
| | Create a view for the buffer given a shape, type and scope. More...
|
| |
| virtual void | FreeView (Device dev, void *data) |
| | Release the view . More...
|
| |
| virtual void | Free (const Buffer &buffer)=0 |
| | Free a buffer allocated by the allocator. More...
|
| |
| virtual void | Clear () |
| | Clear the allocated memory. More...
|
| |
| virtual size_t | UsedMemory () const =0 |
| | The amount of memory currently allocated. More...
|
| |
|
| virtual bool | AllowMemoryScope (const std::string &mem_scope) const |
| | Check if the given memory scope is allowed to allocate by the allocator. More...
|
| |
◆ Allocator()
◆ ~Allocator()
| virtual tvm::runtime::memory::Allocator::~Allocator |
( |
| ) |
|
|
virtualdefault |
◆ Alloc() [1/2]
| virtual Buffer tvm::runtime::memory::Allocator::Alloc |
( |
Device |
dev, |
|
|
ffi::Shape |
shape, |
|
|
DLDataType |
type_hint, |
|
|
const std::string & |
mem_scope = "" |
|
) |
| |
|
virtual |
Allocate a buffer given a shape and type.
- Parameters
-
| dev | The device where the array is allocated. |
| shape | The shape of the tensor. |
| type_hint | A type hint to the allocator. |
| mem_scope | A memory scope of the buffer. |
- Returns
- A sized allocation in the form of a buffer.
◆ Alloc() [2/2]
| virtual Buffer tvm::runtime::memory::Allocator::Alloc |
( |
Device |
dev, |
|
|
size_t |
nbytes, |
|
|
size_t |
alignment, |
|
|
DLDataType |
type_hint |
|
) |
| |
|
pure virtual |
Allocate a buffer given a size, alignment and type.
- Parameters
-
| dev | The device where the array is allocated. |
| nbytes | The size of the buffer. |
| alignment | The alignment of the buffer. |
| type_hint | A type hint to the allocator. |
- Returns
- A sized allocation in the form of a buffer.
◆ AllowMemoryScope()
| virtual bool tvm::runtime::memory::Allocator::AllowMemoryScope |
( |
const std::string & |
mem_scope | ) |
const |
|
protectedvirtual |
Check if the given memory scope is allowed to allocate by the allocator.
◆ Clear()
| virtual void tvm::runtime::memory::Allocator::Clear |
( |
| ) |
|
|
virtual |
Clear the allocated memory.
◆ CreateView()
| virtual void* tvm::runtime::memory::Allocator::CreateView |
( |
const Buffer & |
buffer, |
|
|
ffi::Shape |
shape, |
|
|
DLDataType |
type_hint, |
|
|
const std::string & |
mem_scope = "global" |
|
) |
| |
|
inlinevirtual |
Create a view for the buffer given a shape, type and scope.
- Parameters
-
| buffer | The existing buffer upon which we need to create a view. |
| shape | The shape of the view. |
| type_hint | A type hint to the view. |
| mem_scope | A memory scope of the view. |
- Returns
- A device pointer to the created view.
◆ Empty()
| Tensor tvm::runtime::memory::Allocator::Empty |
( |
ffi::Shape |
shape, |
|
|
DLDataType |
dtype, |
|
|
Device |
dev, |
|
|
ffi::Optional< ffi::String > |
mem_scope = std::nullopt |
|
) |
| |
Allocate an empty Tensor using from the allocator.
- Parameters
-
| shape | The shape of the Tensor. |
| dtype | The datatype of the Tensor. |
| dev | The device where the array is allocated. |
| mem_scope | The device memory scope hint. |
- Returns
- The empty Tensor.
◆ Free()
| virtual void tvm::runtime::memory::Allocator::Free |
( |
const Buffer & |
buffer | ) |
|
|
pure virtual |
Free a buffer allocated by the allocator.
- Parameters
-
| buffer | The buffer to free. |
◆ FreeView()
| virtual void tvm::runtime::memory::Allocator::FreeView |
( |
Device |
dev, |
|
|
void * |
data |
|
) |
| |
|
inlinevirtual |
Release the view .
- Parameters
-
| dev | is the device where this view is created |
| data | The view pointer to be freed. |
◆ type()
Return the allocator type.
◆ UsedMemory()
| virtual size_t tvm::runtime::memory::Allocator::UsedMemory |
( |
| ) |
const |
|
pure virtual |
The amount of memory currently allocated.
- Returns
- The amount of memory currently allocated.
The documentation for this class was generated from the following file: