ai.onnx.MatMulInteger
ai.onnx · standard ONNX operator · ONNX opset ≥ 10
Description
Computes an integer matrix product with 8-bit inputs, int32 accumulation, and independently optional zero points that default to 0. The package implements rank-1 dot products, rank-2 products, rank-2/rank-3 broadcasting, rank-3 products, and rank-4-by-rank-4 products. Scalar zero points are supported throughout; b_zero_point additionally supports [N] for rank-2 B and [batch, 1, N] for non-broadcast rank-3 B. Other standard ONNX matmul rank combinations and N-D per-row/per-column zero-point layouts are not yet implemented.
See the ONNX MatMulInteger spec for the reference semantics.
Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
A |
a |
TA |
— | — | N-dimensional integer matrix A (int8 or uint8). | required |
B |
b |
TB |
— | — | N-dimensional integer matrix B (int8 or uint8). | required |
a_zero_point |
a_zero_point |
TA |
— | — | Optional scalar zero point for A; defaults to 0. Standard N-D per-row layouts are not yet implemented. | optional |
b_zero_point |
b_zero_point |
TB |
— | — | Optional zero point for B; defaults to 0. Supports a scalar, [N] for rank-2 B, or [batch, 1, N] for non-broadcast rank-3 B; other standard N-D per-column layouts are not yet implemented. |
optional |
Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
Y |
y |
TY |
derived | ONNX MatMul result of A and B |
int32 matrix product result of A * B. | required |
Type constraints
| Variable | Allowed dtypes |
|---|---|
TA |
uint8, int8 |
TB |
uint8, int8 |
TY |
int32 |
Files
metadata.json— kernel metadata (id, digests, provenance)manifest.json— the op contract (source of truth)test.json— correctness casesbench.json— benchmark + tuning casesmatmul-integer-batched.wgsl.jinjaquant-dp4a-matmul.wgsl.jinjaquant-matmul-accumulate-rank2.wgsl.jinjaquant-matmul-accumulate-rank4.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.MatMulInteger", { version: 1 });
const { y } = await kernel({ a: { data: aData, shape: [1, 1] }, b: { data: bData, shape: [1, 1] } });
- Downloads last month
- -
Requires WebGPU support. See the compatibility table.