ai.onnx.LpPool
ai.onnx · standard ONNX operator · ONNX opset ≥ 18
Description
Applies Lp pooling over a spatial input tensor by computing the Lp norm within each kernel window and writing the result to the output. Output spatial dimensions are determined by the kernel size, strides, padding, and ceil_mode; p controls which norm is used (e.g. p=1 for sum-of-absolutes, p=2 for Euclidean).
See the ONNX LpPool spec for the reference semantics.
Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
X |
x |
T |
— | — | Input tensor of shape (N x C x D1 x ... x Dn); for images the spatial axes are H and W. |
required |
Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
Y |
y |
T |
same as X |
derived; see description | Output tensor after Lp pooling; spatial dimensions vary with kernel, stride, and pad settings. | required |
Attributes
Attributes and default values (overridable per request):
| Attribute | Default | Description |
|---|---|---|
p |
2 |
The exponent of the Lp norm used for pooling; default 2 gives Euclidean (L2) pooling. |
auto_pad |
"NOTSET" |
Deprecated auto-padding mode (NOTSET, SAME_UPPER, SAME_LOWER, or VALID). It cannot be used together with pads. |
ceil_mode |
0 |
When non-zero, uses ceil instead of floor to compute output spatial dimensions. |
kernel_shape |
— | Required kernel shape, with one positive value per spatial axis. |
strides |
— | Stride along each spatial axis. When omitted, every stride is 1. |
pads |
— | Padding at the beginning and end of each spatial axis, ordered as [begin_0, ..., begin_n, end_0, ..., end_n]. When omitted, every pad is 0. |
dilations |
— | Dilation along each spatial axis. When omitted, every dilation is 1. |
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 casespool-global-reduction.wgsl.jinjapool-ncl1d-x4.wgsl.jinjapool-window-nd.wgsl.jinjapool-window-unroll.wgsl.jinjapool2d-nchw-k2s2-vec4.wgsl.jinjapool2d-nchw-separable.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.LpPool", { version: 1 });
const { y } = await kernel({ x: { data: xData, shape: [1, 1, 4] } }, {
attrs: { kernel_shape: [3] },
});
- Downloads last month
- -
Requires WebGPU support. See the compatibility table.