ai.onnx.Conv
ai.onnx · standard ONNX operator · ONNX opset ≥ 11
Description
Applies an N-dimensional convolution to the input tensor X using filter weights W and an optional bias B. Supports grouped convolution, explicit per-axis padding, dilation, and stride along each spatial dimension.
See the ONNX Conv spec for the reference semantics.
Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
X |
x |
T |
— | — | Input data tensor of shape (N x C x D1 x ... x Dn), where N is the batch size and C is the number of channels. |
required |
W |
w |
T |
— | — | Convolution filter weights of shape (M x C/group x k1 x ... x kn), where M is the number of output feature maps. |
required |
B |
bias |
T |
1 |
— | Optional 1D bias of length M added to each output channel. | optional |
Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
Y |
y |
T |
same as X |
derived; see description | Output tensor whose spatial dimensions are determined by the kernel size, strides, dilations, and padding. | required |
Attributes
Attributes and default values (overridable per request):
| Attribute | Default | Description |
|---|---|---|
auto_pad |
"NOTSET" |
Automatic padding mode. NOTSET uses pads; SAME_UPPER and SAME_LOWER choose padding so each output spatial size is ceil(input / stride); VALID uses no padding. |
group |
1 |
Number of groups that input and output channels are split into; defaults to 1. |
dilations |
— | Optional dilation factors, one positive integer per spatial axis. Omission means all ones. |
kernel_shape |
— | Optional kernel shape, one positive integer per spatial axis. When present, it must match the spatial dimensions of the weight tensor; omission infers the shape from the weights. |
pads |
— | Optional explicit padding in ONNX order [begin_axis_0, ..., begin_axis_n, end_axis_0, ..., end_axis_n]. Omission means all zeros; it cannot be combined with an automatic padding mode. |
strides |
— | Optional stride factors, one positive integer per spatial axis. Omission means all ones. |
Type constraints
| Variable | Allowed dtypes |
|---|---|
T |
float32, float16 |
Device requirements
Some implementation variants require subgroup-matrix and subgroups. These are route-specific capabilities, not package-wide requirements; availability also depends on the request shape and dtype.
Files
metadata.json— kernel metadata (id, digests, provenance)manifest.json— the op contract (source of truth)test.json— correctness casesbench.json— benchmark + tuning casesconv-1x1-channel-reduce.wgsl.jinjaconv-1x1-gemm-tiled-reg.wgsl.jinjaconv-1x1-gemm-tiled.wgsl.jinjaconv-1x1-subgroup-matrix.wgsl.jinjaconv-direct-nd.wgsl.jinjaconv-direct-unrolled.wgsl.jinjaconv-im2col-ncdhw.wgsl.jinjaconv-im2col-nchw.wgsl.jinjaconv-splitk-reduce.wgsl.jinjaconv1d-tiled-reg.wgsl.jinjaconv2d-grouped-large-w4.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.Conv", { version: 1 });
const { y } = await kernel({
x: { data: xData, shape: [1, 1, 7] },
w: { data: wData, shape: [1, 1, 1] },
});
- Downloads last month
- -
Requires WebGPU support. See the compatibility table.