ai.onnx.RMSNormalization
ai.onnx · standard ONNX operator · ONNX opset ≥ 23
Description
Computes RMS normalization over the suffix dimensions of X starting at axis: Y = X / sqrt(mean(X^2) + epsilon) * scale. The normalization stage supports TensorProto stash_type values 1 (float32) and 10 (float16), and is cast back to the dtype of X before scale is applied. The input type T and scale/output type V may independently be float16 or float32; ONNX's bfloat16 and double cases are not yet implemented.
See the ONNX RMSNormalization spec for the reference semantics.
Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
X |
x |
T |
— | — | Input tensor to be normalized; the RMS is taken over the last dimensions starting at axis. |
required |
scale |
scale |
V |
— | — | Scale tensor, unidirectionally broadcastable to X; its dtype V may differ from the input dtype T. |
required |
Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
Y |
y |
V |
same as X |
same as X |
Normalized and scaled output tensor; same shape as X and same dtype V as scale. |
required |
Attributes
Default values (overridable per request):
| Attribute | Default | Description |
|---|---|---|
axis |
-1 |
The first dimension of the normalization suffix; negative values count from the end, so the default -1 normalizes over only the last dimension. |
epsilon |
0.00001 |
Small constant added to the mean square before taking the square root to avoid division by zero. |
stash_type |
1 |
TensorProto element type used for normalization: 1 computes in float32, while 10 computes in float16. |
Type constraints
| Variable | Allowed dtypes |
|---|---|
T |
float32, float16 |
V |
float32, float16 |
Files
metadata.json— kernel metadata (id, digests, provenance)manifest.json— the op contract (source of truth)test.json— correctness casesbench.json— benchmark + tuning casesnorm-row-stats.wgsl.jinjarms-normalization-splitk-normalize.wgsl.jinjarms-normalization-splitk-partials.wgsl.jinjarms-normalization-stash-f16-serial.wgsl.jinjarms-normalization.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.RMSNormalization", { version: 1 });
const { y } = await kernel({
x: { data: xData, shape: [1, 2, 3] },
scale: { data: scaleData, shape: [3] },
});
- Downloads last month
- -
Requires WebGPU support. See the compatibility table.