ai.onnx.LRN
ai.onnx · standard ONNX operator · ONNX opset ≥ 13
Description
Applies Local Response Normalization across the channel dimension of an input tensor of shape (N x C x D1 x ... x Dk): each element is divided by (bias + alpha / size * square_sum) ^ beta, where square_sum is the sum of squares over a local window of size channels centered on that channel.
See the ONNX LRN spec for the reference semantics.
Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
X |
x |
T |
4 |
— | Input data tensor of shape (N x C x H x W) or (N x C x D1 x ... x Dk). |
required |
Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
Y |
y |
T |
same as X |
same as X |
Output tensor with the same shape and type as the input. | required |
Attributes
Attributes and default values (overridable per request):
| Attribute | Default | Description |
|---|---|---|
alpha |
0.0001 |
Scaling parameter applied to the sum of squares. |
beta |
0.75 |
Exponent applied to the normalization term. |
bias |
1 |
Additive constant in the normalization denominator. |
size |
— | Required positive number of channels to sum over in the local normalization window. |
Type constraints
| Variable | Allowed dtypes |
|---|---|
T |
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 caseslrn-nchw.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.LRN", { version: 1 });
const { y } = await kernel({ x: { data: xData, shape: [1, 3, 1, 1] } }, {
attrs: { size: 3 },
});
- Downloads last month
- -
Requires WebGPU support. See the compatibility table.