For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo struct
VarlenConvIO
struct VarlenConvIO[x_origin: Origin[mut=x_origin.mut], weight_origin: Origin[mut=weight_origin.mut], bias_origin: Origin[mut=bias_origin.mut], out_origin: MutOrigin, x_dtype: DType, weight_dtype: DType, bias_dtype: DType, out_dtype: DType, x_layout: TensorLayout, weight_layout: TensorLayout, bias_layout: TensorLayout, out_layout: TensorLayout, x_store: TensorStorage, weight_store: TensorStorage, bias_store: TensorStorage, out_store: TensorStorage, x_addr: AddressSpace, weight_addr: AddressSpace, bias_addr: AddressSpace, out_addr: AddressSpace, x_idx: DType, weight_idx: DType, bias_idx: DType, out_idx: DType, //]
Owner of the forward-path DRAM reads/writes for varlen causal conv1d.
Holds the (dim, seqlen) input x, (dim, width) weight, (dim,)
bias, and (dim, seqlen) output TileTensor views and exposes one
method per access verb, so the forward path indexes with logical
coordinates (t.load(Coord(...)), t.store[width=1](Coord(...), v))
instead of hand-rolled raw_load/raw_store offset arithmetic. Each
view's own RuntimeLayout computes the identical offset the explicit
d*stride + s*stride form did, so this is behavior-preserving.
Every view parameter (dtype, layout, origin, storage, address space, index
type) is inferred from the constructor arguments, so the owner adapts to
whatever tensor storage the caller's views carry -- the CPU reference and
GPU kernel pass differently-parameterized views. The read views (x,
weight, bias) carry origins with a free mut (the CPU reference passes
them immutable, the GPU kernel mutable; reads need no mutability proof); the
store target output pins MutOrigin so store type-checks. Modeled on
the owner-per-transition pattern (see Fp4WeightLoader in
matmul2d_fp4.mojo), constructed by direct field init so no origin rebase
is needed. Stateless: the circular conv-state position is not owned here, so
the same owner serves any path.
Parametersβ
- βx_origin (
Origin[mut=x_origin.mut]): Inferred origin of the input view. - β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. - βx_dtype (
DType): Input element type. - βweight_dtype (
DType): Weight element type. - βbias_dtype (
DType): Bias element type. - βout_dtype (
DType): Output element type. - βx_layout (
TensorLayout): Layout type of the(dim, seqlen)input view. - β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(dim, seqlen)output view. - βx_store (
TensorStorage): Inferred storage of the input view. - βweight_store (
TensorStorage): Inferred storage of the weight view. - βbias_store (
TensorStorage): Inferred storage of the bias view. - βout_store (
TensorStorage): Inferred storage of the output view. - βx_addr (
AddressSpace): Inferred address space of the input 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. - βx_idx (
DType): Inferred linear-index type of the input 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.
Fieldsβ
- βx (
TileTensor[x_dtype, x_layout, x_origin, Storage=x_store, address_space=x_addr, linear_idx_type=x_idx]): - βweight (
TileTensor[weight_dtype, weight_layout, weight_origin, Storage=weight_store, address_space=weight_addr, linear_idx_type=weight_idx]): - βbias (
TileTensor[bias_dtype, bias_layout, bias_origin, Storage=bias_store, address_space=bias_addr, linear_idx_type=bias_idx]): - βoutput (
TileTensor[out_dtype, out_layout, out_origin, Storage=out_store, address_space=out_addr, linear_idx_type=out_idx]):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable
Methodsβ
load_xβ
def load_x(self, d: Int, s: Int) -> Scalar[x_dtype]
Load x[d, s]: windowed history read of the input.
Returns:
load_weightβ
def load_weight(self, d: Int, w: Int) -> Scalar[weight_dtype]
Load weight[d, w]: per-channel conv tap.
Returns:
load_biasβ
def load_bias(self, d: Int) -> Scalar[bias_dtype]
Load bias[d]: per-channel bias.
Returns:
store_outβ
def store_out(self, d: Int, s: Int, val: Scalar[out_dtype])
Store output[d, s] = val: convolution output.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!