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;
78 virtual void Free(
const Buffer& buffer) = 0;
82 virtual size_t UsedMemory()
const = 0;
110 std::unordered_map<Device, std::unique_ptr<Allocator>> allocators_;
120 NDArray AllocNDArray(
size_t offset, std::vector<int64_t>
shape, DLDataType dtype);
123 static void Deleter(
Object* ptr);
131 static constexpr
const char* _type_key =
"vm.Storage";
147 #endif // TVM_RUNTIME_VM_MEMORY_MANAGER_H_ Definition: memory_manager.h:41
AllocatorType type() const
Return the allocator type.
Definition: memory_manager.h:67
Device device
The context of the allocated buffers.
Definition: memory_manager.h:47
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Definition: memory_manager.h:52
AllocatorType
Definition: memory_manager.h:50
base class of all object containers.
Definition: object.h:167
static MemoryManager * Global()
Managed NDArray. The array is backed by reference counted blocks.
Definition: ndarray.h:51
Definition: memory_manager.h:51
#define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:744
A device-independent managed NDArray abstraction.
Buffer buffer
The index into the VM function table.
Definition: memory_manager.h:117
static Allocator * GetAllocator(Device dev)
Get an allocator given the context.
void * data
The pointer to the allocated block of memory.
Definition: memory_manager.h:43
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:1768
DLDevice Device
Definition: ndarray.h:43
Base class of all object reference.
Definition: object.h:511
A managed object in the TVM runtime.
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
virtual void Free(const Buffer &buffer)=0
Free a buffer allocated by the allocator.
Definition: memory_manager.h:88
size_t size
The size of the block.
Definition: memory_manager.h:45
~StorageObj()
Definition: memory_manager.h:125
An object representing a storage allocation.
Definition: memory_manager.h:114
Definition: memory_manager.h:55
Type index is allocated during runtime.
Definition: object.h:80
reference to storage.
Definition: memory_manager.h:136
Allocator(AllocatorType type)
Definition: memory_manager.h:57