23 #ifndef TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_
24 #define TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_
31 #include <unordered_map>
40 #define RELAX_VM_VERSION "0.14"
78 void Save(dmlc::Stream* writer)
const;
79 bool Load(dmlc::Stream* reader);
179 void SaveGlobalSection(dmlc::Stream* strm);
184 void SaveConstantSection(dmlc::Stream* strm);
189 void SaveCodeSection(dmlc::Stream* strm);
194 void SavePackedFuncNames(dmlc::Stream* strm);
199 void LoadGlobalSection(dmlc::Stream* strm);
204 void LoadConstantSection(dmlc::Stream* strm);
209 void LoadCodeSection(dmlc::Stream* strm);
214 void LoadPackedFuncNames(dmlc::Stream* strm);
The bytecode for the virtual machine.
Base container of module.
Definition: module.h:142
Module container of TVM.
Definition: module.h:79
Reference to string objects.
Definition: string.h:97
The virtual machine executable emitted by the VM compiler.
Definition: executable.h:88
void SaveToBinary(dmlc::Stream *stream) final
Write the VMExecutable to the binary stream in serialized form.
TVM_MODULE_VTABLE_ENTRY("as_text", &VMExecutable::AsText)
void SaveToFile(const String &file_name, const String &format) final
Write the VMExecutable to the provided path as a file containing its serialized content.
TVM_MODULE_VTABLE_ENTRY("vm_profiler_load_executable", &VMExecutable::VMProfilerLoadExecutable)
TVM_MODULE_VTABLE_BEGIN("relax.VMExecutable")
std::vector< VMFuncInfo > func_table
The virtual machine's function table.
Definition: executable.h:153
String AsText() const
Print the instructions as text format.
Instruction GetInstruction(Index i) const
Get the i-th instruction from the executable.
bool HasFunction(const String &name) const
Check if the VMExecutable contains a specific function.
TVM_MODULE_VTABLE_ENTRY("stats", &VMExecutable::Stats)
static Module LoadFromBinary(void *stream)
Load VMExecutable from the binary stream in serialized form.
static Module LoadFromFile(const String &file_name)
Load VMExecutable from the file.
void SetInstructionData(Index i, Index j, ExecWord val)
Set j-th byte data of i-th instruction to val.
Module VMLoadExecutable() const
Create a Relax virtual machine and load this as the executable.
virtual ~VMExecutable()
Definition: executable.h:163
std::vector< Index > instr_offset
The offset of instruction.
Definition: executable.h:159
TVM_MODULE_VTABLE_ENTRY("as_python", &VMExecutable::AsPython)
std::unordered_map< std::string, Index > func_map
A map from globals (as strings) to their index in the function map.
Definition: executable.h:155
String AsPython() const
Print the instructions as python program.
std::vector< TVMRetValue > constants
The global constant pool.
Definition: executable.h:157
TVM_MODULE_VTABLE_ENTRY("has_function", &VMExecutable::HasFunction)
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,...
std::vector< ExecWord > instr_data
The byte data of instruction.
Definition: executable.h:161
int GetPropertyMask() const final
Get the property of the runtime module .
Definition: executable.h:91
TVM_MODULE_VTABLE_ENTRY("vm_load_executable", &VMExecutable::VMLoadExecutable)
Definition: executable.h:221
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
Performance counters for profiling via the PAPI library.
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:52
bool Load(dmlc::Stream *reader)
FuncKind kind
The kind of function.
Definition: executable.h:63
FuncKind
kind of the function.
Definition: executable.h:54
@ kVMTIRFunc
VMTIR function.
@ kPackedFunc
system level packed function
Index num_args
The number of arguments of the function.
Definition: executable.h:71
void Save(dmlc::Stream *writer) const
Index start_instr
The start instruction index of the function.
Definition: executable.h:67
Index register_file_size
The register file size of the function.
Definition: executable.h:73
Index end_instr
The end instruction index of the function.
Definition: executable.h:69
std::vector< std::string > param_names
The function parameter names.
Definition: executable.h:75
std::string name
The function's name, global symbol.
Definition: executable.h:65