tvm
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
tvm::runtime::vm::VMExecutable Class Reference

The virtual machine executable emitted by the VM compiler. More...

#include <executable.h>

Inheritance diagram for tvm::runtime::vm::VMExecutable:
Collaboration diagram for tvm::runtime::vm::VMExecutable:

Public Member Functions

int GetPropertyMask () const final
 Get the property of the runtime module . More...
 
std::string Stats () const
 Print the detailed statistics of the given code, i.e. number of globals and constants, etc. More...
 
Instruction GetInstruction (Index i) const
 Get the i-th instruction from the executable. More...
 
void SetInstructionData (Index i, Index j, ExecWord val)
 Set j-th byte data of i-th instruction to val. More...
 
String AsText () const
 Print the instructions as text format. More...
 
String AsPython () const
 Print the instructions as python program. More...
 
ffi::Bytes SaveToBytes () const final
 Write the VMExecutable to the binary stream in serialized form. More...
 
void WriteToFile (const String &file_name, const String &format) const final
 Write the VMExecutable to the provided path as a file containing its serialized content. More...
 
ffi::Module VMLoadExecutable () const
 Create a Relax virtual machine and load this as the executable. More...
 
ffi::Module VMProfilerLoadExecutable () const
 Create a Relax virtual machine with profiler and load this as the executable. More...
 
bool HasFunction (const String &name) const
 Check if the VMExecutable contains a specific function. More...
 
virtual ~VMExecutable ()
 
 TVM_MODULE_VTABLE_BEGIN ("relax.VMExecutable")
 
 TVM_MODULE_VTABLE_ENTRY ("stats", &VMExecutable::Stats)
 
 TVM_MODULE_VTABLE_ENTRY ("as_text", &VMExecutable::AsText)
 
 TVM_MODULE_VTABLE_ENTRY ("as_python", &VMExecutable::AsPython)
 
 TVM_MODULE_VTABLE_ENTRY ("vm_load_executable", &VMExecutable::VMLoadExecutable)
 
 TVM_MODULE_VTABLE_ENTRY ("vm_profiler_load_executable", &VMExecutable::VMProfilerLoadExecutable)
 
 TVM_MODULE_VTABLE_ENTRY ("has_function", &VMExecutable::HasFunction)
 
 TVM_MODULE_VTABLE_END ()
 

Static Public Member Functions

static ffi::Module LoadFromBytes (const ffi::Bytes &bytes)
 Load VMExecutable from the binary stream in serialized form. More...
 
static ffi::Module LoadFromFile (const String &file_name)
 Load VMExecutable from the file. More...
 

Public Attributes

std::vector< VMFuncInfofunc_table
 The virtual machine's function table. More...
 
std::unordered_map< std::string, Indexfunc_map
 A map from globals (as strings) to their index in the function map. More...
 
std::vector< ffi::Any > constants
 The global constant pool. More...
 
std::vector< Indexinstr_offset
 The offset of instruction. More...
 
std::vector< ExecWordinstr_data
 The byte data of instruction. More...
 

Detailed Description

The virtual machine executable emitted by the VM compiler.

The executable contains information (e.g. data in different memory regions) to run in a virtual machine.

Constructor & Destructor Documentation

◆ ~VMExecutable()

virtual tvm::runtime::vm::VMExecutable::~VMExecutable ( )
inlinevirtual

Member Function Documentation

◆ AsPython()

String tvm::runtime::vm::VMExecutable::AsPython ( ) const

Print the instructions as python program.

Returns
The python program of the instructions, represented by a string.

◆ AsText()

String tvm::runtime::vm::VMExecutable::AsText ( ) const

Print the instructions as text format.

Returns
The text format of the instructions.

◆ GetInstruction()

Instruction tvm::runtime::vm::VMExecutable::GetInstruction ( Index  i) const

Get the i-th instruction from the executable.

Parameters
iThe index of the instruction to be fetched.
Returns
The instruction.

◆ GetPropertyMask()

int tvm::runtime::vm::VMExecutable::GetPropertyMask ( ) const
inlinefinal

Get the property of the runtime module .

◆ HasFunction()

bool tvm::runtime::vm::VMExecutable::HasFunction ( const String &  name) const

Check if the VMExecutable contains a specific function.

◆ LoadFromBytes()

static ffi::Module tvm::runtime::vm::VMExecutable::LoadFromBytes ( const ffi::Bytes &  bytes)
static

Load VMExecutable from the binary stream in serialized form.

Parameters
bytesThe binary bytes that load the executable from.
Returns
The loaded executable, in the form of a runtime::Module.

◆ LoadFromFile()

static ffi::Module tvm::runtime::vm::VMExecutable::LoadFromFile ( const String &  file_name)
static

Load VMExecutable from the file.

Parameters
file_nameThe path of the file that load the executable from.
Returns
The loaded executable, in the form of a runtime::Module.

◆ SaveToBytes()

ffi::Bytes tvm::runtime::vm::VMExecutable::SaveToBytes ( ) const
final

Write the VMExecutable to the binary stream in serialized form.

Returns
The binary bytes that save the executable to.

◆ SetInstructionData()

void tvm::runtime::vm::VMExecutable::SetInstructionData ( Index  i,
Index  j,
ExecWord  val 
)

Set j-th byte data of i-th instruction to val.

Parameters
iThe index of the instruction to be updated.
jThe index of the byte data of the instruction to be updated.
valThe value to be set

◆ Stats()

std::string tvm::runtime::vm::VMExecutable::Stats ( ) const

Print the detailed statistics of the given code, i.e. number of globals and constants, etc.

Returns
The statistics represented by a string.

◆ TVM_MODULE_VTABLE_BEGIN()

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_BEGIN ( "relax.VMExecutable"  )

◆ TVM_MODULE_VTABLE_END()

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_END ( )

◆ TVM_MODULE_VTABLE_ENTRY() [1/6]

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_ENTRY ( "as_python"  ,
&VMExecutable::AsPython   
)

◆ TVM_MODULE_VTABLE_ENTRY() [2/6]

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_ENTRY ( "as_text"  ,
&VMExecutable::AsText   
)

◆ TVM_MODULE_VTABLE_ENTRY() [3/6]

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_ENTRY ( "has_function"  ,
&VMExecutable::HasFunction   
)

◆ TVM_MODULE_VTABLE_ENTRY() [4/6]

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_ENTRY ( "stats"  ,
&VMExecutable::Stats   
)

◆ TVM_MODULE_VTABLE_ENTRY() [5/6]

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_ENTRY ( "vm_load_executable"  ,
&VMExecutable::VMLoadExecutable   
)

◆ TVM_MODULE_VTABLE_ENTRY() [6/6]

tvm::runtime::vm::VMExecutable::TVM_MODULE_VTABLE_ENTRY ( "vm_profiler_load_executable"  ,
&VMExecutable::VMProfilerLoadExecutable   
)

◆ VMLoadExecutable()

ffi::Module tvm::runtime::vm::VMExecutable::VMLoadExecutable ( ) const

Create a Relax virtual machine and load this as the executable.

◆ VMProfilerLoadExecutable()

ffi::Module tvm::runtime::vm::VMExecutable::VMProfilerLoadExecutable ( ) const

Create a Relax virtual machine with profiler and load this as the executable.

◆ WriteToFile()

void tvm::runtime::vm::VMExecutable::WriteToFile ( const String &  file_name,
const String &  format 
) const
final

Write the VMExecutable to the provided path as a file containing its serialized content.

Parameters
file_nameThe name of the file to write the serialized data to.
formatThe target format of the saved file.

Member Data Documentation

◆ constants

std::vector<ffi::Any> tvm::runtime::vm::VMExecutable::constants

The global constant pool.

◆ func_map

std::unordered_map<std::string, Index> tvm::runtime::vm::VMExecutable::func_map

A map from globals (as strings) to their index in the function map.

◆ func_table

std::vector<VMFuncInfo> tvm::runtime::vm::VMExecutable::func_table

The virtual machine's function table.

◆ instr_data

std::vector<ExecWord> tvm::runtime::vm::VMExecutable::instr_data

The byte data of instruction.

◆ instr_offset

std::vector<Index> tvm::runtime::vm::VMExecutable::instr_offset

The offset of instruction.


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