com.microsoft.GemmFastGelu

com.microsoft · ONNX Runtime contrib operator · contrib since_version 1

Description

Fuses MatMul, an optional bias, and FastGelu: Y = FastGelu(X @ W + bias). X has rank at least 2 with shape (..., K), W has shape (K, N), and bias has shape (N). The activation runs in the float32 accumulator before the output is narrowed, avoiding an intermediate (..., N) tensor. Bfloat16 is not implemented.

See the ONNX Runtime GemmFastGelu contrib-operator spec for the reference semantics.

Inputs

Name Bind key Logical dtype Rank Shape Description Presence
X X T Left operand of rank 2 or greater with shape (..., K); every leading-axis coordinate identifies a row of the product. required
W W T 2 Right operand with shape (K, N). required
bias bias T 1 Optional bias with shape (N), added before the activation. optional

Outputs

Name Bind key Logical dtype Rank Shape Description Presence
Y Y T same as X ONNX MatMul result of X and W FastGelu(X @ W + bias), with the same rank and leading dimensions as X and a trailing N. required

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

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/com.microsoft.GemmFastGelu", { version: 1 });
const { Y } = await kernel({ X: { data: XData, shape: [5, 6] }, W: { data: WData, shape: [6, 4] } });
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.