For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
VarlenConvIO
struct VarlenConvIO[weight_origin: Origin[mut=weight_origin.mut], bias_origin: Origin[mut=bias_origin.mut], out_origin: MutOrigin, dtype: DType, weight_layout: TensorLayout, bias_layout: TensorLayout, out_layout: TensorLayout, weight_engine: TensorEngine, bias_engine: TensorEngine, out_engine: TensorEngine, weight_addr: AddressSpace, bias_addr: AddressSpace, out_addr: AddressSpace, weight_idx: DType, bias_idx: DType, out_idx: DType, XFn: def[width: Int, alignment: Int](Int, Int) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, //, channels_last: Bool]
Owner of the forward-path DRAM reads/writes for varlen causal conv1d.
Holds the input reader, the (dim, width) weight, (dim,) bias, and
output TileTensor views and exposes one method per access verb.
x and output are the caller's physical tensors: (dim, seqlen), or
(seqlen, dim) when channels_last. The methods take the logical
(d, s) and order the coordinates by channels_last, so the axis order stays
out of the kernels.
Every view parameter is inferred from the constructor arguments, so the
owner adapts to whatever storage the caller's views carry; the CPU
reference and the GPU kernels pass differently-parameterized views. Only
the store target output pins a mutable origin.
Parameters
- weight_origin (
Origin[mut=weight_origin.mut]): Inferred origin of the weight view. - bias_origin (
Origin[mut=bias_origin.mut]): Inferred origin of the bias view. - out_origin (
MutOrigin): Inferred mutable origin of the output view. - dtype (
DType): Element type ofx,weight,biasandoutput. - weight_layout (
TensorLayout): Layout type of the(dim, width)weight view. - bias_layout (
TensorLayout): Layout type of the(dim,)bias view. - out_layout (
TensorLayout): Layout type of the output view. - weight_engine (
TensorEngine): Inferred engine of the weight view. - bias_engine (
TensorEngine): Inferred engine of the bias view. - out_engine (
TensorEngine): Inferred engine of the output view. - weight_addr (
AddressSpace): Inferred address space of the weight view. - bias_addr (
AddressSpace): Inferred address space of the bias view. - out_addr (
AddressSpace): Inferred address space of the output view. - weight_idx (
DType): Inferred linear-index type of the weight view. - bias_idx (
DType): Inferred linear-index type of the bias view. - out_idx (
DType): Inferred linear-index type of the output view. - XFn (
def[width: Int, alignment: Int](Int, Int) -> SIMD[dtype, width]&RegisterPassable&ImplicitlyCopyable): Inferred reader ofxat its physical(row, column)index. - channels_last (
Bool): Whetherxandoutputare(seqlen, dim)rather than(dim, seqlen).
Fields
- x_fn (
XFn): - weight (
TileTensor[dtype, weight_layout, weight_origin, Engine=weight_engine, address_space=weight_addr, linear_idx_type=weight_idx]): - bias (
TileTensor[dtype, bias_layout, bias_origin, Engine=bias_engine, address_space=bias_addr, linear_idx_type=bias_idx]): - output (
TileTensor[dtype, out_layout, out_origin, Engine=out_engine, address_space=out_addr, linear_idx_type=out_idx]):
Implemented traits
AnyType,
Copyable,
Deinitable,
ImplicitlyCopyable,
Movable
Methods
dim
load_x
def load_x[width: Int = Int(1)](self, d: Int, s: Int) -> SIMD[dtype, width]
Load x[d:d + width, s]: windowed history read of the input.
Parameters:
- width (
Int): The number of consecutive channels; above 1 needschannels_last, where they are contiguous.
Args:
Returns:
load_weight
def load_weight(self, d: Int, w: Int) -> Scalar[dtype]
Load weight[d, w]: per-channel conv tap.
Args:
- d (
Int): The channel index into the(dim, width)weight view. - w (
Int): The convolution tap index in[0, width).
Returns:
load_bias
def load_bias[width: Int = Int(1)](self, d: Int) -> SIMD[dtype, width]
Load bias[d:d + width], or zero when bias is empty.
Parameters:
- width (
Int): The number of consecutive channels.
Args:
- d (
Int): The first channel index into the(dim,)bias view.
Returns:
store_out
def store_out[width: Int = Int(1)](self, d: Int, s: Int, val: SIMD[dtype, width])
Store output[d:d + width, s] = val: convolution output.
Parameters:
- width (
Int): The number of consecutive channels, as inload_x.
Args:
- d (
Int): The first channel index. - s (
Int): The packed sequence position. - val (
SIMD[dtype, width]): The convolution result to store.