23 #ifndef TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_
24 #define TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_
32 #include <unordered_map>
41 #define RELAX_VM_VERSION "0.14"
79 void Save(dmlc::Stream* writer)
const;
80 bool Load(dmlc::Stream* reader);
180 void SaveGlobalSection(dmlc::Stream* strm);
185 void SaveConstantSection(dmlc::Stream* strm);
190 void SaveCodeSection(dmlc::Stream* strm);
195 void SavePackedFuncNames(dmlc::Stream* strm);
200 void LoadGlobalSection(dmlc::Stream* strm);
205 void LoadConstantSection(dmlc::Stream* strm);
210 void LoadCodeSection(dmlc::Stream* strm);
215 void LoadPackedFuncNames(dmlc::Stream* strm);
Base container of module.
Definition: module.h:142
Module container of TVM.
Definition: module.h:79
Reference to string objects.
Definition: string.h:98
The executable emitted by the VM compiler.
Definition: executable.h:89
bool HasFunction(const String &name) const
Check if the Executable contains a specific function.
String AsText() const
Print the instructions as text format.
TVM_MODULE_VTABLE_BEGIN("relax.Executable")
int GetPropertyMask() const final
Get the property of the runtime module .
Definition: executable.h:92
TVM_MODULE_VTABLE_ENTRY("stats", &Executable::Stats)
static Module LoadFromFile(const String &file_name)
Load Executable from the file.
virtual ~Executable()
Definition: executable.h:164
std::unordered_map< std::string, Index > func_map
A map from globals (as strings) to their index in the function map.
Definition: executable.h:156
Instruction GetInstruction(Index i) const
Get the i-th instruction from the executable.
TVM_MODULE_VTABLE_ENTRY("as_text", &Executable::AsText)
Module VMLoadExecutable() const
Create a Relax virtual machine and load this as the executable.
static Module LoadFromBinary(void *stream)
Load Executable from the binary stream in serialized form.
TVM_MODULE_VTABLE_ENTRY("vm_load_executable", &Executable::VMLoadExecutable)
std::vector< VMFuncInfo > func_table
The virtual machine's function table.
Definition: executable.h:154
TVM_MODULE_VTABLE_ENTRY("has_function", &Executable::HasFunction)
String AsPython() const
Print the instructions as python program.
std::vector< TVMRetValue > constants
The global constant pool.
Definition: executable.h:158
void SaveToFile(const String &file_name, const String &format) final
Write the Executable to the provided path as a file containing its serialized content.
void SaveToBinary(dmlc::Stream *stream) final
Write the Executable to the binary stream in serialized form.
TVM_MODULE_VTABLE_ENTRY("vm_profiler_load_executable", &Executable::VMProfilerLoadExecutable)
std::vector< Index > instr_offset
The offset of instruction.
Definition: executable.h:160
TVM_MODULE_VTABLE_ENTRY("as_python", &Executable::AsPython)
std::vector< ExecWord > instr_data
The byte data of instruction.
Definition: executable.h:162
Module VMProfilerLoadExecutable() const
Create a Relax virtual machine with profiler and load this as the executable.
std::string Stats() const
Print the detailed statistics of the given code, i.e. number of globals and constants,...
void SetInstructionData(Index i, Index j, ExecWord val)
Set j-th byte data of i-th instruction to val.
Runtime Closure container types.
Definition: executable.h:222
DMLC_DECLARE_TRAITS(has_saveload, ::tvm::runtime::relax_vm::VMFuncInfo, true)
ExecWord Index
An alias for the integer type used ubiquitously in the VM.
Definition: bytecode.h:48
int64_t ExecWord
The storage type for the bytecode in the VM.
Definition: bytecode.h:40
@ kBinarySerializable
kBinarySerializable we can serialize the module to the stream of bytes. CUDA/OpenCL/JSON runtime are ...
Definition: module.h:56
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A managed object in the TVM runtime.
Type-erased function used across TVM API.
This file defines the TVM global function registry.
A single virtual machine instruction.
Definition: bytecode.h:72
Information entry in executable function table.
Definition: executable.h:53
bool Load(dmlc::Stream *reader)
FuncKind kind
The kind of function.
Definition: executable.h:64
FuncKind
kind of the function.
Definition: executable.h:55
@ kVMTIRFunc
VMTIR function.
@ kPackedFunc
system level packed function
Index num_args
The number of arguments of the function.
Definition: executable.h:72
void Save(dmlc::Stream *writer) const
Index start_instr
The start instruction index of the function.
Definition: executable.h:68
Index register_file_size
The register file size of the function.
Definition: executable.h:74
Index end_instr
The end instruction index of the function.
Definition: executable.h:70
std::vector< std::string > param_names
The function parameter names.
Definition: executable.h:76
std::string name
The function's name, global symbol.
Definition: executable.h:66
The bytecode for Relay virtual machine.