tvm
|
A single virtual machine instruction. More...
#include <bytecode.h>
Public Member Functions | |
Instruction () | |
Instruction (const Instruction &instr) | |
Instruction & | operator= (const Instruction &instr) |
~Instruction () | |
Static Public Member Functions | |
static Instruction | Ret (RegName return_reg) |
Construct a return instruction. More... | |
static Instruction | Fatal () |
Construct a fatal instruction. More... | |
static Instruction | InvokePacked (Index packed_index, Index arity, Index output_size, const std::vector< RegName > &args) |
Construct a invoke packed instruction. More... | |
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. More... | |
static Instruction | AllocTensorReg (RegName storage, Index offset, RegName shape_register, DLDataType dtype, RegName dst) |
Construct an allocate tensor instruction with register. More... | |
static Instruction | AllocADT (Index tag, Index num_fields, const std::vector< RegName > &fields, RegName dst) |
Construct an allocate datatype instruction. More... | |
static Instruction | AllocClosure (Index func_index, Index num_freevar, const std::vector< RegName > &free_vars, RegName dst) |
Construct an allocate closure instruction. More... | |
static Instruction | GetField (RegName object_reg, Index field_index, RegName dst) |
Construct a get field instruction. More... | |
static Instruction | GetTag (RegName object_reg, RegName dst) |
Construct a get_tag instruction. More... | |
static Instruction | If (RegName test, RegName target, Index true_branch, Index false_branch) |
Construct an if instruction. More... | |
static Instruction | Goto (Index pc_offset) |
Construct a goto instruction. More... | |
static Instruction | Invoke (Index func_index, const std::vector< RegName > &args, RegName dst) |
Construct an invoke instruction. More... | |
static Instruction | InvokeClosure (RegName closure, const std::vector< RegName > &args, RegName dst) |
Construct an invoke closure instruction. More... | |
static Instruction | LoadConst (Index const_index, Index device_index, RegName dst) |
Construct a load constant instruction. More... | |
static Instruction | LoadConsti (Index val, RegName dst) |
Construct a load_constanti instruction. More... | |
static Instruction | Move (RegName src, RegName dst) |
Construct a move instruction. More... | |
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. More... | |
static Instruction | ShapeOf (RegName tensor, RegName dst) |
Get the shape of an input tensor. More... | |
static Instruction | ReshapeTensor (RegName tensor, RegName newshape, RegName dst) |
Reshape the tensor given the new shape. More... | |
static Instruction | DeviceCopy (RegName src, Index src_device_index, Index dst_device_index, RegName dst) |
Copy tensor cross different devices. More... | |
static Instruction | KillRegister (RegName dst) |
Public Attributes | |
Opcode | op |
The instruction opcode. More... | |
RegName | dst |
The destination register. More... | |
union { | |
struct { | |
RegName storage | |
The storage to allocate from. More... | |
Index offset | |
The offset into the storage to allocate from. More... | |
uint32_t ndim | |
The number of dimensions. More... | |
int64_t * shape | |
The shape of tensor. More... | |
DLDataType dtype | |
The datatype of tensor to be allocated. More... | |
} alloc_tensor | |
struct { | |
RegName storage | |
The storage to allocate from. More... | |
Index offset | |
The offset into the storage to allocate from. More... | |
RegName shape_register | |
The register to read the shape out of. More... | |
DLDataType dtype | |
The datatype of tensor to be allocated. More... | |
} alloc_tensor_reg | |
struct { | |
RegName closure | |
The register containing the closure. More... | |
Index num_closure_args | |
The number of arguments to the closure. More... | |
RegName * closure_args | |
The closure arguments as an array. More... | |
} | |
struct { | |
RegName result | |
The register to return. More... | |
} | |
struct { | |
RegName from | |
The source register for a move operation. More... | |
} | |
struct { | |
Index packed_index | |
The index into the packed function table. More... | |
Index arity | |
The arity of the packed function. More... | |
Index output_size | |
The number of outputs produced by the packed function. More... | |
RegName * packed_args | |
The arguments to pass to the packed function. More... | |
} | |
struct { | |
RegName test | |
The register containing the test value. More... | |
RegName target | |
The register containing the target value. More... | |
Index true_offset | |
The program counter offset for the true branch. More... | |
Index false_offset | |
The program counter offset for the false branch. More... | |
} if_op | |
struct { | |
Index func_index | |
The function to call. More... | |
Index num_args | |
The number of arguments to the function. More... | |
RegName * invoke_args_registers | |
The registers containing the arguments. More... | |
} | |
struct { | |
Index const_index | |
Index device_index | |
The index of the device on which the load will be made. More... | |
} | |
struct { | |
Index val | |
} load_consti | |
struct { | |
Index pc_offset | |
The jump offset. More... | |
} | |
struct { | |
RegName object | |
The register to project from. More... | |
Index field_index | |
The field to read out. More... | |
} | |
struct { | |
RegName object | |
The register to project from. More... | |
} get_tag | |
struct { | |
Index constructor_tag | |
The datatype's constructor tag. More... | |
Index num_fields | |
The number of fields to store in the datatype. More... | |
RegName * datatype_fields | |
The fields as an array. More... | |
} | |
struct { | |
Index clo_index | |
The index into the function table. More... | |
Index num_freevar | |
The number of free variables to capture. More... | |
RegName * free_vars | |
The free variables as an array. More... | |
} | |
struct { | |
Index alignment | |
The alignment of the allocation. More... | |
DLDataType dtype_hint | |
The hint of the dtype. More... | |
uint32_t ndim | |
The number of dimensions. More... | |
union { | |
int64_t * shape | |
The shape of tensor. More... | |
RegName allocation_size | |
The size of the allocation. More... | |
} | |
Index device_index | |
The index of the device on which the allocation will be made. More... | |
} alloc_storage | |
struct { | |
RegName tensor | |
} shape_of | |
struct { | |
RegName tensor | |
RegName newshape | |
} reshape_tensor | |
struct { | |
RegName src | |
Index src_device_index | |
The index of the source device to copy from. More... | |
Index dst_device_index | |
The index of the destination deviceto copy to. More... | |
} device_copy | |
}; | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Instruction &) |
A single virtual machine instruction.
The representation of the instruction is as a tagged union.
The first field represents which instruction, and by extension which field of the union is active.
tvm::runtime::vm::Instruction::Instruction | ( | ) |
tvm::runtime::vm::Instruction::Instruction | ( | const Instruction & | instr | ) |
tvm::runtime::vm::Instruction::~Instruction | ( | ) |
|
static |
Construct an allocate datatype instruction.
tag | The datatype tag. |
num_fields | The number of fields for the datatype. |
fields | The registers containing the fields. |
dst | The register name of the destination. |
|
static |
Construct an allocate closure instruction.
func_index | The index of the function table. |
num_freevar | The number of free variables. |
free_vars | The registers of the free variables. |
dst | The destination register. |
|
static |
Allocate a storage block.
size | The size of the allocation. |
alignment | The allocation's alignment. |
dtype_hint | The data type hint for the allocator. |
device_index | The index of the device to allocate on. |
shape | The shape of the allocation. |
dst | The destination to place the storage. |
|
static |
Construct an allocate tensor instruction with constant shape.
storage | The storage to allocate out of. |
offset | The offset to allocate at. |
shape | The shape of the tensor. |
dtype | The dtype of the tensor. |
dst | The destination register. |
|
static |
Construct an allocate tensor instruction with register.
storage | The storage to allocate out of. |
offset | The offset into the storage to allocate from. |
shape_register | The register containing the shape. |
dtype | The dtype of the tensor. |
dst | The destination register. |
|
static |
Copy tensor cross different devices.
src | The source register. |
src_device_index | The index of the device holding the tensor in the source register. |
dst_device_index | The index of the device to hold the tensor in the destination register. |
dst | The destination register to store the copied tensor. |
|
static |
Construct a fatal instruction.
|
static |
Construct a get field instruction.
object_reg | The register containing the object to project from. |
field_index | The field to read out of the object. |
dst | The destination register. |
|
static |
Construct a get_tag instruction.
object_reg | The register containing the object to project from. |
dst | The destination register. |
|
static |
Construct a goto instruction.
pc_offset | The offset from the current pc. |
|
static |
Construct an if instruction.
test | The register containing the test value. |
target | The register containing the target value. |
true_branch | The offset to the true branch. |
false_branch | The offset to the false branch. |
|
static |
Construct an invoke instruction.
func_index | The index of the function to invoke. |
args | The registers containing the arguments. |
dst | The destination register. |
|
static |
Construct an invoke closure instruction.
closure | The register of the closure to invoke. |
args | The registers containing the arguments. |
dst | The destination register. |
|
static |
Construct a invoke packed instruction.
packed_index | The index of the packed function. |
arity | The arity of the function. |
output_size | The number of outputs of the packed function. |
args | The argument registers. |
|
static |
|
static |
Construct a load constant instruction.
const_index | The index of the constant. |
device_index | The index of the device to load on. |
dst | The destination register. |
|
static |
Construct a load_constanti instruction.
val | The interger constant value. |
dst | The destination register. |
|
static |
Construct a move instruction.
src | The source register. |
dst | The destination register. |
Instruction& tvm::runtime::vm::Instruction::operator= | ( | const Instruction & | instr | ) |
|
static |
Reshape the tensor given the new shape.
tensor | The input tensor. |
newshape | The shape tensor. |
dst | The destination to store the output tensor with new shape. |
|
static |
Construct a return instruction.
return_reg | The register containing the return value. |
|
static |
Get the shape of an input tensor.
tensor | The input tensor. |
dst | The destination to store the shape of the given tensor. |
|
friend |
union { ... } |
Index tvm::runtime::vm::Instruction::alignment |
The alignment of the allocation.
struct { ... } tvm::runtime::vm::Instruction::alloc_storage |
struct { ... } tvm::runtime::vm::Instruction::alloc_tensor |
struct { ... } tvm::runtime::vm::Instruction::alloc_tensor_reg |
RegName tvm::runtime::vm::Instruction::allocation_size |
The size of the allocation.
Index tvm::runtime::vm::Instruction::arity |
The arity of the packed function.
Index tvm::runtime::vm::Instruction::clo_index |
The index into the function table.
RegName tvm::runtime::vm::Instruction::closure |
The register containing the closure.
RegName* tvm::runtime::vm::Instruction::closure_args |
The closure arguments as an array.
Index tvm::runtime::vm::Instruction::const_index |
Index tvm::runtime::vm::Instruction::constructor_tag |
The datatype's constructor tag.
RegName* tvm::runtime::vm::Instruction::datatype_fields |
The fields as an array.
struct { ... } tvm::runtime::vm::Instruction::device_copy |
Index tvm::runtime::vm::Instruction::device_index |
The index of the device on which the load will be made.
The index of the device on which the allocation will be made.
RegName tvm::runtime::vm::Instruction::dst |
The destination register.
Index tvm::runtime::vm::Instruction::dst_device_index |
The index of the destination deviceto copy to.
DLDataType tvm::runtime::vm::Instruction::dtype |
The datatype of tensor to be allocated.
DLDataType tvm::runtime::vm::Instruction::dtype_hint |
The hint of the dtype.
Index tvm::runtime::vm::Instruction::false_offset |
The program counter offset for the false branch.
Index tvm::runtime::vm::Instruction::field_index |
The field to read out.
RegName* tvm::runtime::vm::Instruction::free_vars |
The free variables as an array.
RegName tvm::runtime::vm::Instruction::from |
The source register for a move operation.
Index tvm::runtime::vm::Instruction::func_index |
The function to call.
struct { ... } tvm::runtime::vm::Instruction::get_tag |
struct { ... } tvm::runtime::vm::Instruction::if_op |
RegName* tvm::runtime::vm::Instruction::invoke_args_registers |
The registers containing the arguments.
struct { ... } tvm::runtime::vm::Instruction::load_consti |
uint32_t tvm::runtime::vm::Instruction::ndim |
The number of dimensions.
RegName tvm::runtime::vm::Instruction::newshape |
Index tvm::runtime::vm::Instruction::num_args |
The number of arguments to the function.
Index tvm::runtime::vm::Instruction::num_closure_args |
The number of arguments to the closure.
Index tvm::runtime::vm::Instruction::num_fields |
The number of fields to store in the datatype.
Index tvm::runtime::vm::Instruction::num_freevar |
The number of free variables to capture.
RegName tvm::runtime::vm::Instruction::object |
The register to project from.
Index tvm::runtime::vm::Instruction::offset |
The offset into the storage to allocate from.
Opcode tvm::runtime::vm::Instruction::op |
The instruction opcode.
Index tvm::runtime::vm::Instruction::output_size |
The number of outputs produced by the packed function.
RegName* tvm::runtime::vm::Instruction::packed_args |
The arguments to pass to the packed function.
Index tvm::runtime::vm::Instruction::packed_index |
The index into the packed function table.
Index tvm::runtime::vm::Instruction::pc_offset |
The jump offset.
struct { ... } tvm::runtime::vm::Instruction::reshape_tensor |
RegName tvm::runtime::vm::Instruction::result |
The register to return.
int64_t* tvm::runtime::vm::Instruction::shape |
The shape of tensor.
struct { ... } tvm::runtime::vm::Instruction::shape_of |
RegName tvm::runtime::vm::Instruction::shape_register |
The register to read the shape out of.
RegName tvm::runtime::vm::Instruction::src |
Index tvm::runtime::vm::Instruction::src_device_index |
The index of the source device to copy from.
RegName tvm::runtime::vm::Instruction::storage |
The storage to allocate from.
RegName tvm::runtime::vm::Instruction::target |
The register containing the target value.
RegName tvm::runtime::vm::Instruction::tensor |
RegName tvm::runtime::vm::Instruction::test |
The register containing the test value.
Index tvm::runtime::vm::Instruction::true_offset |
The program counter offset for the true branch.
Index tvm::runtime::vm::Instruction::val |