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

CausalConv1D

struct CausalConv1D[activation: StringSlice[StaticConstantOrigin]]

Causal 1D convolution operation with bias.

Performs causal (autoregressive) 1D convolution where each output position depends only on current and past input positions. Supports optional SiLU activation with SIMD-vectorized implementations for widths 1, 2, 3, 4.

Tensor Shapes: - input: (batch, channels, seqlen) - Input sequence tensor. - weight: (channels, width) - Convolution weights per channel. - bias: (channels,) - Per-channel bias to add. - output: (batch, channels, seqlen) - Output tensor (same shape as input).

Parameters​

  • ​activation (StringSlice[StaticConstantOrigin]): Activation function to apply after convolution.
    • "none": No activation (identity).
    • "silu": SiLU/Swish activation (x * sigmoid(x)).

Implemented traits​

AnyType, ImplicitlyDestructible

Methods​

execute​

static execute[dtype: DType, rank: Int, target: StringSlice[StaticConstantOrigin]](output: ManagedTensorSlice[Output, static_spec=output.static_spec], input: ManagedTensorSlice[Input, static_spec=input.static_spec], weight: ManagedTensorSlice[Input, static_spec=weight.static_spec], bias: ManagedTensorSlice[Input, static_spec=bias.static_spec], ctx: DeviceContext)

shape​

static shape[dtype: DType, rank: Int](input: ManagedTensorSlice[Input, static_spec=input.static_spec], weight: ManagedTensorSlice[Input, static_spec=weight.static_spec], bias: ManagedTensorSlice[Input, static_spec=bias.static_spec]) -> IndexList[rank]

Returns:

IndexList[rank]