ai.onnx.MatMul

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

Description

Computes the matrix product A * B with ONNX MatMul semantics, including vector promotion and NumPy-style broadcasting over batch dimensions. This package currently supports float16, float32, int32, and uint32 tensors. All legal rank-1 through rank-4 combinations are implemented; rank-5 is supported only when both inputs have rank 5, so legal mixed-rank combinations between a rank-5 operand and a rank-1 through rank-4 operand are not yet implemented. Higher-rank inputs and other ONNX-supported types are also not yet implemented.

See the ONNX MatMul spec for the reference semantics.

Inputs

Name Bind key Logical dtype Rank Shape Description Presence
A a T N-dimensional left-hand matrix. required
B b T N-dimensional right-hand matrix. required

Outputs

Name Bind key Logical dtype Rank Shape Description Presence
Y y T derived ONNX MatMul result of A and B Matrix multiply result of A * B, including vector promotion and broadcast batch dimensions. required

Type constraints

Variable Allowed dtypes
T float32, float16, int32, uint32

Device requirements

Some implementation variants require subgroup-matrix, shader-f16, and subgroups. These are route-specific capabilities, not package-wide requirements; availability also depends on the request shape and dtype.

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.MatMul", { version: 1 });
const { y } = await kernel({ a: { data: aData, shape: [3, 5] }, b: { data: bData, shape: [5, 4] } });
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.