ai.onnx.Gather

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

Description

Gathers entries from data along the specified axis using an indices tensor, producing an output of rank q + (r - 1) where r is the rank of data and q is the rank of indices. Each index value selects a (r-1)-dimensional slice from data along axis, and the resulting slices are arranged into the output tensor with the q index dimensions replacing the gathered axis.

See the ONNX Gather spec for the reference semantics.

Inputs

Name Logical dtype Rank Shape Description Presence
data T Tensor of rank r >= 1 to gather entries from. required
indices I Integer index tensor of any rank q; each value must be in [-s, s-1] where s is the size of data along axis. required

Outputs

Name Logical dtype Rank Shape Description Presence
output T derived derived Output tensor of rank q + (r - 1) containing the gathered slices. required

Attributes

Default values (overridable per request):

Attribute Default Description
axis 0 Axis of data along which to gather; negative values count from the back. Accepted range is [-r, r-1] where r = rank(data).

Type constraints

Variable Allowed dtypes
T float32, float16, uint32, int32, int16, uint8, int8, bool
I int32

Files

Use with @huggingface/kernels

npm install --save-exact @huggingface/kernels@0.0.1-preview.2

Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.

The version: 1 option selects the published kernel contract; it is independent of any operator opset, contrib since_version, or model version. It follows the v1 branch as fixes land. To pin exact artifact bytes, pass a 40-character commit revision instead of 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.Gather", { version: 1 });
const { output } = await kernel({
  data: { data: dataData, shape: [4] },
  indices: { data: indicesData, shape: [4] },
});
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.