|
tvm
|
The virtual machine. More...
#include <vm.h>
Public Member Functions | |
| virtual void | Init (const std::vector< Device > &devices, const std::vector< AllocatorType > &alloc_types)=0 |
| Initialize the virtual machine for a set of devices. | |
| virtual void | LoadExecutable (ffi::ObjectPtr< VMExecutable > exec)=0 |
| Load the executable for the virtual machine. | |
| virtual VMClosure | GetClosure (const ffi::String &func_name)=0 |
| Get global function in the VM. | |
| virtual void | InvokeClosurePacked (const ffi::ObjectRef &closure_or_packedfunc, ffi::PackedArgs args, ffi::Any *rv)=0 |
| Invoke closure or packed function using ffi::Function convention. | |
| virtual void | SetInstrument (ffi::Function instrument)=0 |
| Set an instrumentation function. | |
| template<typename T , typename = std::enable_if_t<std::is_base_of<VMExtension, T>::value>> | |
| T | GetOrCreateExtension () |
| Get or create a VM extension. Once created, the extension will be stored in the VM and held until the VM is destructed. | |
| ~VirtualMachine () | |
Static Public Member Functions | |
| static ffi::ObjectPtr< VirtualMachine > | Create () |
| Create a specific instance of VM. | |
| static VirtualMachine * | GetContextPtr (ffi::AnyView arg) |
| Helper function for vm closure functions to get the context ptr. | |
Public Attributes | |
| std::vector< Allocator * > | allocators |
| The memory allocators. | |
| std::vector< Device > | devices |
| Runtime physical device list. | |
| std::unordered_map< uint32_t, Any > | extensions |
| The VM extensions. Mapping from the type index of the extension to the extension instance. | |
The virtual machine.
The virtual machine contains all the current execution state, as well as the executable.
The goal is to have a single self-contained object, enabling one to easily pass around VMs, execute them on multiple threads, or serialize them to disk or over the wire.
|
inline |
|
static |
Create a specific instance of VM.
|
pure virtual |
Get global function in the VM.
| func_name | The name of the function. |
|
inlinestatic |
Helper function for vm closure functions to get the context ptr.
| arg | The argument value. |
|
inline |
Get or create a VM extension. Once created, the extension will be stored in the VM and held until the VM is destructed.
| T | The type of the extension |
|
pure virtual |
Initialize the virtual machine for a set of devices.
| devices | The set of TVM devices. |
| alloc_types | The allocator types for each device. |
|
pure virtual |
Invoke closure or packed function using ffi::Function convention.
| closure_or_packedfunc | A VM closure or a packed_func. |
| args | The input arguments. |
| rv | The return value. |
|
pure virtual |
Load the executable for the virtual machine.
| exec | The executable. |
|
pure virtual |
Set an instrumentation function.
If instrument is present, the function will be called before/after each Call instruction.
bool instrument(func, func_symbol, before_run, args...)
instrument can return an int which corresponds to the action value.
| instrument | The instrument function. |
| std::vector<Allocator*> tvm::runtime::vm::VirtualMachine::allocators |
The memory allocators.
| std::vector<Device> tvm::runtime::vm::VirtualMachine::devices |
Runtime physical device list.
The VM extensions. Mapping from the type index of the extension to the extension instance.