ai.onnx.QLinearMatMul

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

Description

Quantized matrix multiplication of two N-dimensional tensors a and b, following ONNX MatMul broadcasting semantics. Each operand and the output carry their own scale and zero point; the result is requantized via y = saturate((x / y_scale) + y_zero_point), with scales and zero points that may be per-tensor, per-row, or per-column.

See the ONNX QLinearMatMul spec for the reference semantics.

Inputs

Name Bind key Logical dtype Rank Shape Description Presence
a a TA N-dimensional quantized matrix a. required
a_scale a_scale TF 1 Scale of quantized input a; scalar (per-tensor) or per-row vector. required
a_zero_point a_zero_point TA 1 Zero point of quantized input a; must have the same shape as a_scale. required
b b TB N-dimensional quantized matrix b. required
b_scale b_scale TF Scale of quantized input b; scalar (per-tensor) or per-column vector. required
b_zero_point b_zero_point TB Zero point of quantized input b; must have the same shape as b_scale. required
y_scale y_scale TF 1 Scale of quantized output y. required
y_zero_point y_zero_point TY 1 Zero point of quantized output y. required

Outputs

Name Bind key Logical dtype Rank Shape Description Presence
y y TY derived ONNX MatMul result of a and b Quantized matrix multiply result of a * b. required

Type constraints

Variable Allowed dtypes
TA uint8, int8
TB uint8, int8
TY uint8, int8
TF float32, float16

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.QLinearMatMul", { version: 1 });
const { y } = await kernel({
  a: { data: aData, shape: [1, 1] },
  a_scale: { data: a_scaleData, shape: [1] },
  a_zero_point: { data: a_zero_pointData, shape: [1] },
  b: { data: bData, shape: [1, 2] },
  b_scale: { data: b_scaleData, shape: [1] },
  b_zero_point: { data: b_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.