IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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:

Scalar[x_dtype]

load_weight​

def load_weight(self, d: Int, w: Int) -> Scalar[weight_dtype]

Load weight[d, w]: per-channel conv tap.

Returns:

Scalar[weight_dtype]

load_bias​

def load_bias(self, d: Int) -> Scalar[bias_dtype]

Load bias[d]: per-channel bias.

Returns:

Scalar[bias_dtype]

store_out​

def store_out(self, d: Int, s: Int, val: Scalar[out_dtype])

Store output[d, s] = val: convolution output.