ai.onnx.MaxUnpool

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

Description

Computes the partial inverse of MaxPool: each pooled value in X is scattered back to the position given by its index in I, with all other positions set to zero. The optional output_shape input disambiguates the output size when multiple input sizes would produce the same pooled result.

See the ONNX MaxUnpool spec for the reference semantics.

Inputs

Name Bind key Logical dtype WebGPU storage Rank Shape Description Presence
X x T same as logical dtype Pooled input tensor to be unpooled, typically the first output of a MaxPool op, with shape (N x C x D1 x ... x Dn). required
I indices I uint32 Logical int64 flat linear indices of the maximal elements corresponding to X, typically the second output of a MaxPool op; same shape as X and stored as uint32 by WebGPU. required
output_shape output_shape I uint32 1 Optional logical int64 1-D tensor specifying the full non-negative output shape, for example (N, C, H, W). It uses uint32 WebGPU storage and, when provided, causes pads to be ignored. optional

Outputs

Name Bind key Logical dtype Rank Shape Description Presence
output output T same as X Unpooled output tensor with pooled values scattered to their original positions and zeros elsewhere. required

Attributes

Attributes and default values (overridable per request):

Attribute Default Description
kernel_shape The size of the pooling kernel along each spatial axis; required and must match the kernel used in the corresponding MaxPool.
strides Optional stride along each spatial axis. When omitted, output-shape inference uses a stride of 1 along every spatial axis; an explicit list must contain one value per spatial axis.
pads Optional padding at the beginning and end of each spatial axis in [x1_begin, x2_begin, ..., x1_end, x2_end] format. When omitted, output-shape inference uses zero padding; values are ignored when output_shape is provided, and an explicit list must contain two values per spatial axis.

Type constraints

Variable Allowed dtypes
T float32, float16
I int64

Files

Use with @huggingface/kernels

The loader automatically allocates outputs whose metadata it can derive from the manifest contract and this call.

The explicit outputs entries provide shape and logical dtype metadata for the results listed below:

  • output

Each entry either requests an optional result or supplies metadata that cannot be inferred from the inputs.

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.MaxUnpool", { version: 1 });
// Explicit destinations request optional results or supply metadata that cannot be inferred.
const { output } = await kernel({
  x: { data: xData, shape: [1, 1, 4] },
  indices: { data: indicesData, shape: [1, 1, 4] },
}, {
  attrs: { kernel_shape: [2] },
  outputs: { output: { shape: [1, 1, 5], dtype: "float32" } },
});
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.