library_name: kernels
license: apache-2.0
tags:
- kernel
- webgpu
- wgsl
com.microsoft.CausalConvWithState
com.microsoft · ONNX Runtime contrib operator · contrib since_version 1
Description
Legacy Microsoft contrib form of stateful 1-D causal depthwise convolution. Each channel uses its own (channels, 1, kernel) weight over current and past positions, with optional activation and past_state/present_state tensors for incremental decoding. The contrib-only state_window attribute may retain several rollback states. This inference implementation preserves the existing contrib ABI with ndim = 1, float16 or float32 tensors, and float32 accumulation; spatial ranks 2 and 3 and bfloat16 are not implemented.
See the ONNX Runtime CausalConvWithState contrib-operator spec for the reference semantics.
Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
input |
inputT |
T |
3 |
— | Channels-first input tensor with shape (batch_size, channels, sequence_length) for the supported 1-D mode. |
required |
weight |
weightT |
T |
3 |
— | Depthwise convolution kernel with shape (channels, 1, kernel_size) for the supported 1-D mode. |
required |
bias |
biasT |
T |
1 |
— | Optional per-channel bias with shape (channels,). |
optional |
past_state |
pastStateT |
T |
derived | — | Carry state from the previous step; shape (batch_size, channels, k_1 - 1), or (W, batch_size, channels, k_1 - 1) when state_window = W > 0, in which case only slot W - 1 is read. If absent, the left-side padding is zero. |
optional |
Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
output |
outputT |
T |
3 |
same as input |
Convolution output with the same shape as input. |
required |
present_state |
presentStateT |
T |
derived | derived; see description | Updated carry state; shape (batch_size, channels, k_1 - 1), or (W, batch_size, channels, k_1 - 1) when state_window = W > 0. Slot W - 1 holds the last k - 1 values along the causal axis; slot j holds the same for the prefix ending at position seq_len - W + j. |
required |
Attributes
Default values (overridable per request):
| Attribute | Default | Description |
|---|---|---|
activation |
"none" |
Activation applied after convolution and bias. Defaults to none; swish is an alias of SiLU. |
ndim |
1 |
Number of spatial dimensions. This implementation supports the contrib 1D mode (ndim = 1). |
state_window |
0 |
Contrib extension selecting the number of rollback state slots to retain, in the range 0 through 8. Defaults to 0. |
Type constraints
| Variable | Allowed dtypes |
|---|---|
T |
float32, float16 |
Files
metadata.json— kernel metadata (id, digests, provenance)manifest.json— the op contract (source of truth)test.json— correctness casesbench.json— benchmark + tuning casescausal-conv-with-state-tiled.wgsl.jinjacausal-conv-with-state-vec4.wgsl.jinjacausal-conv-with-state.wgsl.jinja
Use with @huggingface/kernels
The loader derives every required output's shape and logical dtype from the manifest contract and this call. It then allocates the result tensors automatically.
The version: 1 option selects the published kernel contract; it is independent of any operator opset, contrib since_version, or model version.
Replace each *Data placeholder with a typed array containing the corresponding input data.
import { getKernel } from "@huggingface/kernels";
const kernel = await getKernel("webgpu-kernels/com.microsoft.CausalConvWithState", { version: 1 });
const { outputT, presentStateT } = await kernel({
inputT: { data: inputTData, shape: [1, 1, 5] },
weightT: { data: weightTData, shape: [1, 1, 4] },
});