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
CausalConv1DVarlenFwd
struct CausalConv1DVarlenFwd[activation: StaticString, channels_last: Bool = False, use_residual: Bool = False]
Varlen causal 1D convolution forward pass.
Performs causal 1D convolution on variable-length sequences that are concatenated together. Uses cumulative sequence lengths to identify sequence boundaries.
channels_last=True lets a tokens-major caller skip the transposes on
both sides of the op.
Tensor Shapes:
- output: (dim, total_seqlen) - Output tensor
((total_seqlen, dim) when channels_last)
- x: (dim, total_seqlen) - Input tensor (concatenated sequences)
((total_seqlen, dim) when channels_last)
- weight: (dim, width) - Convolution weights per channel
- bias: (dim,) - Per-channel bias
- query_start_loc: (batch + 1,) - Cumulative sequence lengths
- cache_indices: (batch,) or (1, batch) - Indices into conv_states
(optional)
- has_initial_state: (batch,) - Whether to use initial state (optional)
- update_state: (batch,) - Whether to write the new window back to
conv_states (optional; empty writes every sequence's)
- conv_states: (batch, dim, width - 1) - Conv states (optional, in/out)
Parameters
- activation (
StaticString): Activation function - "none" or "silu". - channels_last (
Bool): If True,xandoutputare tokens-major (total_seqlen, dim) instead of (dim, total_seqlen). - use_residual (
Bool): If True, addsx[d, s]to the convolution sum at each output position, beforeactivation.
Implemented traits
Methods
execute
static def execute(output: T, x: T, weight: T, bias: T, conv_states: T, query_start_loc: T, cache_indices: T, has_initial_state: T, update_state: T, ctx: DeviceContext)