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: StringSpan[ImmStaticOrigin], 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,) - Indices into conv_states (optional)
- has_initial_state: (batch,) - Whether to use initial state (optional)
- conv_states: (batch, dim, width - 1) - Conv states (optional, in/out)
Parameters
- activation (
StringSpan[ImmStaticOrigin]): 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[dtype: DType, conv_states_dtype: DType, target: StringSpan[ImmStaticOrigin]](output: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=output.static_spec], x: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=x.static_spec], weight: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=weight.static_spec], bias: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=bias.static_spec], conv_states: ManagedTensorSlice[IOSpec[_, _].MutableInput, static_spec=conv_states.static_spec], query_start_loc: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=query_start_loc.static_spec], cache_indices: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=cache_indices.static_spec], has_initial_state: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=has_initial_state.static_spec], ctx: DeviceContext)