24 #ifndef TVM_RUNTIME_VM_BYTECODE_H_
25 #define TVM_RUNTIME_VM_BYTECODE_H_
28 #include <tvm/runtime/logging.h>
251 const std::vector<RegName>& args);
int64_t Index
An alias for the integer type used ubiquitously in the VM.
Definition: bytecode.h:43
int64_t RegName
A register name.
Definition: bytecode.h:38
Opcode
An enumeration of Relay's opcodes.
Definition: bytecode.h:50
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A single virtual machine instruction.
Definition: bytecode.h:83
Index offset
The offset into the storage to allocate from.
Definition: bytecode.h:95
RegName shape_register
The register to read the shape out of.
Definition: bytecode.h:109
RegName object
The register to project from.
Definition: bytecode.h:173
DLDataType dtype_hint
The hint of the dtype.
Definition: bytecode.h:203
static Instruction Fatal()
Construct a fatal instruction.
struct tvm::runtime::vm::Instruction::@11::@23 if_op
int64_t * shape
The shape of tensor.
Definition: bytecode.h:99
static Instruction Move(RegName src, RegName dst)
Construct a move instruction.
uint32_t ndim
The number of dimensions.
Definition: bytecode.h:97
RegName dst
The destination register.
Definition: bytecode.h:88
struct tvm::runtime::vm::Instruction::@11::@33 get_tag
Index false_offset
The program counter offset for the false branch.
Definition: bytecode.h:147
Instruction(const Instruction &instr)
RegName tensor
Definition: bytecode.h:216
RegName * datatype_fields
The fields as an array.
Definition: bytecode.h:188
static Instruction Ret(RegName return_reg)
Construct a return instruction.
struct tvm::runtime::vm::Instruction::@11::@14 alloc_tensor_reg
Index dst_device_index
The index of the destination deviceto copy to.
Definition: bytecode.h:227
RegName storage
The storage to allocate from.
Definition: bytecode.h:93
Index arity
The arity of the packed function.
Definition: bytecode.h:133
RegName closure
The register containing the closure.
Definition: bytecode.h:115
static Instruction Goto(Index pc_offset)
Construct a goto instruction.
Index num_fields
The number of fields to store in the datatype.
Definition: bytecode.h:186
RegName target
The register containing the target value.
Definition: bytecode.h:143
RegName allocation_size
The size of the allocation.
Definition: bytecode.h:210
RegName from
The source register for a move operation.
Definition: bytecode.h:127
static Instruction GetField(RegName object_reg, Index field_index, RegName dst)
Construct a get field instruction.
RegName newshape
Definition: bytecode.h:220
Index true_offset
The program counter offset for the true branch.
Definition: bytecode.h:145
RegName * packed_args
The arguments to pass to the packed function.
Definition: bytecode.h:137
Index num_args
The number of arguments to the function.
Definition: bytecode.h:153
static Instruction ShapeOf(RegName tensor, RegName dst)
Get the shape of an input tensor.
Index field_index
The field to read out.
Definition: bytecode.h:175
Index src_device_index
The index of the source device to copy from.
Definition: bytecode.h:225
Instruction & operator=(const Instruction &instr)
Index output_size
The number of outputs produced by the packed function.
Definition: bytecode.h:135
RegName * invoke_args_registers
The registers containing the arguments.
Definition: bytecode.h:155
RegName src
Definition: bytecode.h:223
RegName * free_vars
The free variables as an array.
Definition: bytecode.h:197
Index pc_offset
The jump offset.
Definition: bytecode.h:169
Index constructor_tag
The datatype's constructor tag.
Definition: bytecode.h:184
static Instruction ReshapeTensor(RegName tensor, RegName newshape, RegName dst)
Reshape the tensor given the new shape.
friend std::ostream & operator<<(std::ostream &os, const Instruction &)
static Instruction LoadConsti(Index val, RegName dst)
Construct a load_constanti instruction.
static Instruction InvokePacked(Index packed_index, Index arity, Index output_size, const std::vector< RegName > &args)
Construct a invoke packed instruction.
static Instruction KillRegister(RegName dst)
static Instruction GetTag(RegName object_reg, RegName dst)
Construct a get_tag instruction.
Index alignment
The alignment of the allocation.
Definition: bytecode.h:201
DLDataType dtype
The datatype of tensor to be allocated.
Definition: bytecode.h:101
Index const_index
Definition: bytecode.h:159
static Instruction AllocStorage(RegName size, Index alignment, DLDataType dtype_hint, Index device_index, const std::vector< int64_t > &shape, RegName dst)
Allocate a storage block.
struct tvm::runtime::vm::Instruction::@11::@38 alloc_storage
Opcode op
The instruction opcode.
Definition: bytecode.h:85
static Instruction AllocADT(Index tag, Index num_fields, const std::vector< RegName > &fields, RegName dst)
Construct an allocate datatype instruction.
Index func_index
The function to call.
Definition: bytecode.h:151
static Instruction LoadConst(Index const_index, Index device_index, RegName dst)
Construct a load constant instruction.
Index clo_index
The index into the function table.
Definition: bytecode.h:193
struct tvm::runtime::vm::Instruction::@11::@28 load_consti
struct tvm::runtime::vm::Instruction::@11::@41 device_copy
Index val
Definition: bytecode.h:165
Index packed_index
The index into the packed function table.
Definition: bytecode.h:131
static Instruction Invoke(Index func_index, const std::vector< RegName > &args, RegName dst)
Construct an invoke instruction.
struct tvm::runtime::vm::Instruction::@11::@40 reshape_tensor
static Instruction DeviceCopy(RegName src, Index src_device_index, Index dst_device_index, RegName dst)
Copy tensor cross different devices.
Index num_closure_args
The number of arguments to the closure.
Definition: bytecode.h:117
Index num_freevar
The number of free variables to capture.
Definition: bytecode.h:195
RegName test
The register containing the test value.
Definition: bytecode.h:141
RegName result
The register to return.
Definition: bytecode.h:123
struct tvm::runtime::vm::Instruction::@11::@39 shape_of
static Instruction If(RegName test, RegName target, Index true_branch, Index false_branch)
Construct an if instruction.
RegName * closure_args
The closure arguments as an array.
Definition: bytecode.h:119
static Instruction AllocTensor(RegName storage, Index offset, const std::vector< int64_t > &shape, DLDataType dtype, RegName dst)
Construct an allocate tensor instruction with constant shape.
static Instruction AllocTensorReg(RegName storage, Index offset, RegName shape_register, DLDataType dtype, RegName dst)
Construct an allocate tensor instruction with register.
static Instruction AllocClosure(Index func_index, Index num_freevar, const std::vector< RegName > &free_vars, RegName dst)
Construct an allocate closure instruction.
Index device_index
The index of the device on which the load will be made.
Definition: bytecode.h:161
struct tvm::runtime::vm::Instruction::@11::@13 alloc_tensor
static Instruction InvokeClosure(RegName closure, const std::vector< RegName > &args, RegName dst)
Construct an invoke closure instruction.