ai.onnx.Split
ai.onnx · standard ONNX operator · ONNX opset ≥ 18
Description
Splits a tensor into a list of tensors along the specified axis. The number of parts and their sizes come from the optional split input, or from num_outputs equal parts, the last smaller when the axis does not divide evenly; without either, the call passes the parts, each with its shape.
See the ONNX Split spec for the reference semantics.
Inputs
| Name | Logical dtype | WebGPU storage | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
input |
T |
runtime-selected; narrow integers and bool use 32-bit slots | — | — | The tensor to split. | required |
split |
S |
uint32 |
1 |
— | Optional logical int64 1-D tensor specifying the size of each output along the split axis; values must be non-negative, sum to the axis dimension, and use uint32 WebGPU storage. | optional |
Outputs
| Name | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|
outputs |
T |
same as input |
derived per tensor | Part i of the input along axis. |
1 to 5 tensors |
Attributes
Attributes and default values (overridable per request):
| Attribute | Default | Description |
|---|---|---|
axis |
0 |
The axis along which to split. Negative values count from the end; accepted range is [-rank, rank-1]. |
num_outputs |
— | Optional number of outputs when the split input is omitted. The final output may be smaller when the axis dimension is not evenly divisible. |
Type constraints
| Variable | Allowed dtypes |
|---|---|
T |
float32, float16, uint32, int32, int16, uint8, int8, bool, int64 |
S |
int64 |
Files
metadata.json— kernel metadata (id, file digests, manifest spec, provenance)manifest.json— the op contract (source of truth)test.json— correctness casesbench.json— benchmark casesdatamove-flat-copy.wgsl.jinjadatamove-split-block.wgsl.jinjadatamove-split-n.wgsl.jinja
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.Split", { version: 1 });
const inputData = Float32Array.of(1, 2, 3, 4, 5, 6);
const splitData = Uint32Array.of(2, 4);
const { outputs } = await kernel({
input: { data: inputData, shape: [6] },
split: { data: splitData, shape: [2] },
});
console.log({ outputs });
- Downloads last month
- -
Requires WebGPU support. See the compatibility table.