ai.onnx.CausalConvWithState
ai.onnx · standard ONNX operator · ONNX opset ≥ 27
Description
Stateful causal 1-D depthwise convolution. It left-pads each channel with past_state (or zeros), applies a (channels, 1, kernel_size) depthwise convolution and optional SiLU/Swish activation, and returns both the output and the last kernel_size - 1 values as present_state. This inference implementation supports float16 and float32 tensors; bfloat16 is not yet implemented.
See the ONNX CausalConvWithState spec for the reference semantics.
Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
input |
inputT |
T |
3 |
— | Input tensor with shape (batch_size, channels, length) in channels-first layout. |
required |
weight |
weightT |
T |
3 |
— | Depthwise convolution kernel with shape (channels, 1, kernel_size), matching the ONNX Conv weight layout for group = channels. |
required |
bias |
biasT |
T |
1 |
— | Optional per-channel bias with shape (channels). |
optional |
past_state |
pastStateT |
T |
3 |
— | Carry state from the previous step with shape (batch_size, channels, kernel_size - 1). If omitted, the left 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 |
3 |
derived; see description | Updated carry state with shape (batch_size, channels, kernel_size - 1), including prior state or zero-padding when the current input is shorter than the state. |
required |
Attributes
Default values (overridable per request):
| Attribute | Default | Description |
|---|---|---|
activation |
"none" |
Optional fused activation. silu and swish are aliases; none leaves the convolution result unchanged. |
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/ai.onnx.CausalConvWithState", { version: 1 });
const { outputT, presentStateT } = await kernel({
inputT: { data: inputTData, shape: [1, 1, 2] },
weightT: { data: weightTData, shape: [1, 1, 5] },
});
- Downloads last month
- -
Requires WebGPU support. See the compatibility table.