tvm
Loading...
Searching...
No Matches
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 .
 
std::string Stats () const
 Print the detailed statistics of the given code, i.e. number of globals and constants, etc.
 
Instruction GetInstruction (Index i) const
 Get the i-th instruction from the executable.
 
void SetInstructionData (Index i, Index j, ExecWord val)
 Set j-th byte data of i-th instruction to val.
 
ffi::String AsText () const
 Print the instructions as text format.
 
ffi::String AsPython () const
 Print the instructions as python program.
 
ffi::Bytes SaveToBytes () const final
 Write the VMExecutable to the binary stream in serialized form.
 
void WriteToFile (const ffi::String &file_name, const ffi::String &format) const final
 Write the VMExecutable to the provided path as a file containing its serialized content.
 
ffi::Module VMLoadExecutable () const
 Create a Relax virtual machine and load this as the executable.
 
bool HasFunction (const ffi::String &name) const
 Check if the VMExecutable contains a specific function.
 
virtual ~VMExecutable ()
 
const charkind () const final
 Module type key.
 
ffi::Optional< ffi::Function > GetFunction (const ffi::String &name) override
 Look up an exported function by name.
 

Static Public Member Functions

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

Public Attributes

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

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()

ffi::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()

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

Print the instructions as text format.

Returns
The text format of the instructions.

◆ GetFunction()

ffi::Optional< ffi::Function > tvm::runtime::vm::VMExecutable::GetFunction ( const ffi::String &  name)
override

Look up an exported function by name.

Parameters
nameThe function name.
Returns
The function if found, otherwise std::nullopt.

◆ 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 ffi::String &  name) const

Check if the VMExecutable contains a specific function.

◆ kind()

const char * tvm::runtime::vm::VMExecutable::kind ( ) const
final

Module type key.

◆ 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 ffi::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.

◆ VMLoadExecutable()

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

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

◆ WriteToFile()

void tvm::runtime::vm::VMExecutable::WriteToFile ( const ffi::String &  file_name,
const ffi::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.

◆ memory_scopes

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

The VDevice memory scopes.


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