ai.onnx.QLinearConv

ai.onnx · standard ONNX operator · ONNX opset ≥ 10

Description

Performs convolution on a quantized input using quantized weights, producing a quantized output. Inputs, weights, and output each carry their own scale and zero-point tensors (per-tensor or per-output-channel); an optional int32 bias must be pre-quantized with scale = x_scale * w_scale and zero point 0.

See the ONNX QLinearConv spec for the reference semantics.

Inputs

Name Bind key Logical dtype Rank Shape Description Presence
x x TX Quantized input data tensor shaped (N x C x D1 x ... x Dn). required
x_scale x_scale TF Per-tensor scale for input x. required
x_zero_point x_zero_point TX Per-tensor zero point for input x. required
w w TW Quantized weight tensor shaped (M x C/group x k1 x ... x kn). required
w_scale w_scale TF Scale for weights w; scalar for per-tensor or 1-D of length M for per-output-channel quantization. required
w_zero_point w_zero_point TW Zero point for weights w; scalar or 1-D of length M matching w_scale. required
y_scale y_scale TF Per-tensor scale for output y. required
y_zero_point y_zero_point TY Per-tensor zero point for output y. required
B B int32 1 Optional 1-D bias of length M, pre-quantized with scale x_scale * w_scale and zero point 0. optional

Outputs

Name Bind key Logical dtype Rank Shape Description Presence
y y TY same as x derived; see description Quantized output tensor; shape is determined by kernel size, strides, 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
TX uint8, int8
TW uint8, int8
TY uint8, int8
TF float32

Files

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.QLinearConv", { version: 1 });
const { y } = await kernel({
  x: { data: xData, shape: [1, 1, 1] },
  x_scale: { data: x_scaleData, shape: [1] },
  x_zero_point: { data: x_zero_pointData, shape: [1] },
  w: { data: wData, shape: [1, 1, 1] },
  w_scale: { data: w_scaleData, shape: [1] },
  w_zero_point: { data: w_zero_pointData, shape: [1] },
  y_scale: { data: y_scaleData, shape: [1] },
  y_zero_point: { data: y_zero_pointData, shape: [1] },
});
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.