tvm
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
tvm::runtime::relax_vm::Executable Class Reference

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

#include <executable.h>

Inheritance diagram for tvm::runtime::relax_vm::Executable:
Collaboration diagram for tvm::runtime::relax_vm::Executable:

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...
 
void SaveToBinary (dmlc::Stream *stream) final
 Write the Executable to the binary stream in serialized form. More...
 
void SaveToFile (const String &file_name, const String &format) final
 Write the Executable to the provided path as a file containing its serialized content. More...
 
Module VMLoadExecutable () const
 Create a Relax virtual machine and load this as the executable. More...
 
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 Executable contains a specific function. More...
 
virtual ~Executable ()
 
 TVM_MODULE_VTABLE_BEGIN ("relax.Executable")
 
 TVM_MODULE_VTABLE_ENTRY ("stats", &Executable::Stats)
 
 TVM_MODULE_VTABLE_ENTRY ("as_text", &Executable::AsText)
 
 TVM_MODULE_VTABLE_ENTRY ("as_python", &Executable::AsPython)
 
 TVM_MODULE_VTABLE_ENTRY ("vm_load_executable", &Executable::VMLoadExecutable)
 
 TVM_MODULE_VTABLE_ENTRY ("vm_profiler_load_executable", &Executable::VMProfilerLoadExecutable)
 
 TVM_MODULE_VTABLE_ENTRY ("has_function", &Executable::HasFunction)
 
 TVM_MODULE_VTABLE_END ()
 
- Public Member Functions inherited from tvm::runtime::ModuleNode
virtual ~ModuleNode ()=default
 virtual destructor More...
 
virtual const char * type_key () const =0
 
virtual PackedFunc GetFunction (const String &name, const ObjectPtr< Object > &sptr_to_self)=0
 Get a PackedFunc from module. More...
 
virtual String GetSource (const String &format="")
 Get the source code of module, when available. More...
 
virtual String GetFormat ()
 Get the format of the module, when available. More...
 
PackedFunc GetFunction (const String &name, bool query_imports=false)
 Get packed function from current module by name. More...
 
void Import (Module other)
 Import another module into this module. More...
 
const PackedFuncGetFuncFromEnv (const String &name)
 Get a function from current environment The environment includes all the imports as well as Global functions. More...
 
void ClearImports ()
 Clear all imports of the module. More...
 
const std::vector< Module > & imports () const
 
bool IsDSOExportable () const
 Returns true if this module is 'DSO exportable'. More...
 
bool IsBinarySerializable () const
 Returns true if this module is 'Binary Serializable'. More...
 
virtual bool ImplementsFunction (const String &name, bool query_imports=false)
 Returns true if this module has a definition for a function of name. If query_imports is true, also search in any imported modules. More...
 
 TVM_DECLARE_FINAL_OBJECT_INFO (ModuleNode, Object)
 
- Public Member Functions inherited from tvm::runtime::Object
uint32_t type_index () const
 
std::string GetTypeKey () const
 
size_t GetTypeKeyHash () const
 
template<typename TargetType >
bool IsInstance () const
 
bool unique () const
 
 Object ()
 
 Object (const Object &other)
 
 Object (Object &&other)
 
Objectoperator= (const Object &other)
 
Objectoperator= (Object &&other)
 

Static Public Member Functions

static Module LoadFromBinary (void *stream)
 Load Executable from the binary stream in serialized form. More...
 
static Module LoadFromFile (const String &file_name)
 Load Executable from the file. More...
 
- Static Public Member Functions inherited from tvm::runtime::Object
static std::string TypeIndex2Key (uint32_t tindex)
 Get the type key of the corresponding index from runtime. More...
 
static size_t TypeIndex2KeyHash (uint32_t tindex)
 Get the type key hash of the corresponding index from runtime. More...
 
static uint32_t TypeKey2Index (const std::string &key)
 Get the type index of the corresponding key from runtime. More...
 
static uint32_t _GetOrAllocRuntimeTypeIndex ()
 
static uint32_t RuntimeTypeIndex ()
 

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< TVMRetValueconstants
 The global constant pool. More...
 
std::vector< Indexinstr_offset
 The offset of instruction. More...
 
std::vector< ExecWordinstr_data
 The byte data of instruction. More...
 

Additional Inherited Members

- Public Types inherited from tvm::runtime::Object
typedef void(* FDeleter) (Object *self)
 Object deleter. More...
 
using RefCounterType = std::atomic< int32_t >
 
- Static Public Attributes inherited from tvm::runtime::ModuleNode
static constexpr const uint32_t _type_index = TypeIndex::kRuntimeModule
 
static constexpr const char * _type_key = "runtime.Module"
 
- Static Public Attributes inherited from tvm::runtime::Object
static constexpr const char * _type_key = "runtime.Object"
 
static constexpr bool _type_final = false
 
static constexpr uint32_t _type_child_slots = 0
 
static constexpr bool _type_child_slots_can_overflow = true
 
static constexpr bool _type_has_method_visit_attrs = true
 
static constexpr bool _type_has_method_sequal_reduce = false
 
static constexpr bool _type_has_method_shash_reduce = false
 
static constexpr uint32_t _type_index = TypeIndex::kDynamic
 
- Protected Member Functions inherited from tvm::runtime::Object
void IncRef ()
 developer function, increases reference counter. More...
 
void DecRef ()
 developer function, decrease reference counter. More...
 
- Static Protected Member Functions inherited from tvm::runtime::Object
static uint32_t GetOrAllocRuntimeTypeIndex (const std::string &key, uint32_t static_tindex, uint32_t parent_tindex, uint32_t type_child_slots, bool type_child_slots_can_overflow)
 Get the type index using type key. More...
 
- Protected Attributes inherited from tvm::runtime::ModuleNode
std::vector< Moduleimports_
 The modules this module depend on. More...
 
- Protected Attributes inherited from tvm::runtime::Object
uint32_t type_index_ {0}
 Type index(tag) that indicates the type of the object. More...
 
RefCounterType ref_counter_ {0}
 The internal reference counter. More...
 
FDeleter deleter_ = nullptr
 deleter of this object to enable customized allocation. If the deleter is nullptr, no deletion will be performed. The creator of the object must always set the deleter field properly. More...
 

Detailed Description

The 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

◆ ~Executable()

virtual tvm::runtime::relax_vm::Executable::~Executable ( )
inlinevirtual

Member Function Documentation

◆ AsPython()

String tvm::runtime::relax_vm::Executable::AsPython ( ) const

Print the instructions as python program.

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

◆ AsText()

String tvm::runtime::relax_vm::Executable::AsText ( ) const

Print the instructions as text format.

Returns
The text format of the instructions.

◆ GetInstruction()

Instruction tvm::runtime::relax_vm::Executable::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::relax_vm::Executable::GetPropertyMask ( ) const
inlinefinalvirtual

Get the property of the runtime module .

Reimplemented from tvm::runtime::ModuleNode.

◆ HasFunction()

bool tvm::runtime::relax_vm::Executable::HasFunction ( const String name) const

Check if the Executable contains a specific function.

◆ LoadFromBinary()

static Module tvm::runtime::relax_vm::Executable::LoadFromBinary ( void *  stream)
static

Load Executable from the binary stream in serialized form.

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

◆ LoadFromFile()

static Module tvm::runtime::relax_vm::Executable::LoadFromFile ( const String file_name)
static

Load Executable 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.

◆ SaveToBinary()

void tvm::runtime::relax_vm::Executable::SaveToBinary ( dmlc::Stream *  stream)
finalvirtual

Write the Executable to the binary stream in serialized form.

Parameters
streamThe binary stream to save the executable to.

Reimplemented from tvm::runtime::ModuleNode.

◆ SaveToFile()

void tvm::runtime::relax_vm::Executable::SaveToFile ( const String file_name,
const String format 
)
finalvirtual

Write the Executable 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.

Reimplemented from tvm::runtime::ModuleNode.

◆ SetInstructionData()

void tvm::runtime::relax_vm::Executable::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::relax_vm::Executable::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::relax_vm::Executable::TVM_MODULE_VTABLE_BEGIN ( "relax.Executable"  )

◆ TVM_MODULE_VTABLE_END()

tvm::runtime::relax_vm::Executable::TVM_MODULE_VTABLE_END ( )

◆ TVM_MODULE_VTABLE_ENTRY() [1/6]

tvm::runtime::relax_vm::Executable::TVM_MODULE_VTABLE_ENTRY ( "as_python"  ,
&Executable::AsPython   
)

◆ TVM_MODULE_VTABLE_ENTRY() [2/6]

tvm::runtime::relax_vm::Executable::TVM_MODULE_VTABLE_ENTRY ( "as_text"  ,
&Executable::AsText   
)

◆ TVM_MODULE_VTABLE_ENTRY() [3/6]

tvm::runtime::relax_vm::Executable::TVM_MODULE_VTABLE_ENTRY ( "has_function"  ,
&Executable::HasFunction   
)

◆ TVM_MODULE_VTABLE_ENTRY() [4/6]

tvm::runtime::relax_vm::Executable::TVM_MODULE_VTABLE_ENTRY ( "stats"  ,
&Executable::Stats   
)

◆ TVM_MODULE_VTABLE_ENTRY() [5/6]

tvm::runtime::relax_vm::Executable::TVM_MODULE_VTABLE_ENTRY ( "vm_load_executable"  ,
&Executable::VMLoadExecutable   
)

◆ TVM_MODULE_VTABLE_ENTRY() [6/6]

tvm::runtime::relax_vm::Executable::TVM_MODULE_VTABLE_ENTRY ( "vm_profiler_load_executable"  ,
&Executable::VMProfilerLoadExecutable   
)

◆ VMLoadExecutable()

Module tvm::runtime::relax_vm::Executable::VMLoadExecutable ( ) const

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

◆ VMProfilerLoadExecutable()

Module tvm::runtime::relax_vm::Executable::VMProfilerLoadExecutable ( ) const

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

Member Data Documentation

◆ constants

std::vector<TVMRetValue> tvm::runtime::relax_vm::Executable::constants

The global constant pool.

◆ func_map

std::unordered_map<std::string, Index> tvm::runtime::relax_vm::Executable::func_map

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

◆ func_table

std::vector<VMFuncInfo> tvm::runtime::relax_vm::Executable::func_table

The virtual machine's function table.

◆ instr_data

std::vector<ExecWord> tvm::runtime::relax_vm::Executable::instr_data

The byte data of instruction.

◆ instr_offset

std::vector<Index> tvm::runtime::relax_vm::Executable::instr_offset

The offset of instruction.


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