ai.onnx.SplitToSequence

ai.onnx · tensor-only contract (non-standard) · reviewed against ONNX opset 11

Description

Splits a tensor into a sequence of tensors along axis: chunks the size of a scalar split, the last smaller where the axis does not divide; parts the sizes a 1-D split lists; or, without split, parts of size 1, which keepdims=0 squeezes. This tensor-only package returns the sequence's elements as its variadic output, one to six of them, rather than an ONNX sequence value.

See the standard ONNX SplitToSequence spec for the graph semantics this tensor-only package does not implement.

Inputs

Name Logical dtype Rank Shape Description Presence
input T — — The tensor to split. required
split I — — Part length: a positive scalar for equal chunks, or a 1-D tensor of positive lengths that sum to the axis dimension. The kernel reads its shape, and its values only to work out the outputs' shapes. optional

Outputs

Name Logical dtype Rank Shape Description Presence
output_sequence T derived derived per tensor Element i of the sequence. 1 to 6 tensors

Attributes

Default values (overridable per request):

Attribute Default Description
axis 0 Axis along which to split; negative values count from the back. Accepted range is [-rank, rank-1].
keepdims 1 Whether to keep the split dimension in the output (default 1). Ignored when split is provided.

Type constraints

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

Files

Use with @huggingface/kernels

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

Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.

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.

import { getKernel } from "@huggingface/kernels";

const kernel = await getKernel("webgpu-kernels/ai.onnx.SplitToSequence", { version: 1 });

const inputData = Float32Array.of(0.27460325, 0.3411136, 0.3648526, 0.33739972, 0.2583308, 0.13555045);

const { output_sequence } = await kernel({ input: { data: inputData, shape: [3, 2] } });
console.log({ output_sequence });
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.