24 #ifndef TVM_RUNTIME_VM_MEMORY_MANAGER_H_
25 #define TVM_RUNTIME_VM_MEMORY_MANAGER_H_
34 #include <unordered_map>
74 virtual Buffer Alloc(
size_t nbytes,
size_t alignment, DLDataType type_hint) = 0;
110 std::unordered_map<Device, std::unique_ptr<Allocator>> allocators_;
Managed NDArray. The array is backed by reference counted blocks.
Definition: ndarray.h:51
Base class of all object reference.
Definition: object.h:515
base class of all object containers.
Definition: object.h:167
Definition: memory_manager.h:55
virtual Buffer Alloc(size_t nbytes, size_t alignment, DLDataType type_hint)=0
Allocate a buffer given a size, alignment and type.
virtual size_t UsedMemory() const =0
The amount of memory currently allocated.
virtual void Free(const Buffer &buffer)=0
Free a buffer allocated by the allocator.
AllocatorType type() const
Return the allocator type.
Definition: memory_manager.h:67
Allocator(AllocatorType type)
Definition: memory_manager.h:57
NDArray Empty(std::vector< int64_t > shape, DLDataType dtype, Device dev)
Allocate an empty NDArray using from the allocator.
virtual ~Allocator()=default
Definition: memory_manager.h:88
static Allocator * GetOrCreateAllocator(Device dev, AllocatorType type)
Get or create an allocator given the context and allocator type.
static MemoryManager * Global()
static Allocator * GetAllocator(Device dev)
Get an allocator given the context.
An object representing a storage allocation.
Definition: memory_manager.h:114
TVM_DECLARE_FINAL_OBJECT_INFO(StorageObj, Object)
static constexpr const char * _type_key
Definition: memory_manager.h:131
~StorageObj()
Definition: memory_manager.h:125
NDArray AllocNDArray(size_t offset, std::vector< int64_t > shape, DLDataType dtype)
Allocate an NDArray from a given piece of storage.
Buffer buffer
The index into the VM function table.
Definition: memory_manager.h:117
static constexpr const uint32_t _type_index
Definition: memory_manager.h:130
static void Deleter(Object *ptr)
The deleter for an NDArray when allocated from underlying storage.
reference to storage.
Definition: memory_manager.h:136
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(Storage, ObjectRef, StorageObj)
AllocatorType
Definition: memory_manager.h:50
@ kPooled
Definition: memory_manager.h:52
@ kNaive
Definition: memory_manager.h:51
Tensor shape(const Tensor &src, DataType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:1763
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
DLDevice Device
Definition: ndarray.h:43
A device-independent managed NDArray abstraction.
A managed object in the TVM runtime.
@ kDynamic
Type index is allocated during runtime.
Definition: object.h:80
Definition: memory_manager.h:41
Device device
The context of the allocated buffers.
Definition: memory_manager.h:47
size_t size
The size of the block.
Definition: memory_manager.h:45
void * data
The pointer to the allocated block of memory.
Definition: memory_manager.h:43