Xenova's picture
Xenova HF Staff
sync 2e7068faf55e
c3bbe43 verified
|
Raw
History Blame
3.66 kB
---
library_name: kernels
license: apache-2.0
tags:
- kernel
- webgpu
- wgsl
---
# ai.onnx.SplitToSequence
`ai.onnx` · internal tensor lowering (non-standard) · reviewed against ONNX opset 11
## Description
Support status: the standard ONNX `SplitToSequence` operator is not implemented because this kernel ABI exposes tensors rather than an ONNX sequence value. This internal lowering copies an input into two, three, four, or six caller-shaped tensor outputs and therefore does not implement the standard `output_sequence` contract; it must not be treated as ONNX `SplitToSequence`.
See the [standard ONNX `SplitToSequence` spec](https://onnx.ai/onnx/operators/onnx__SplitToSequence.html) for the contract this internal lowering does not implement.
## Inputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
| --- | --- | --- | --- | --- | --- | --- |
| `input` | `input` | `T` | — | — | The tensor to split. | required |
| `split` | `split` | `S` | — | — | Length of each output slice: a scalar for uniform chunks or a 1-D tensor of per-output lengths. | optional |
## Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
| --- | --- | --- | --- | --- | --- | --- |
| `Y0` | `y0` | `T` | derived | — | First output tensor slice. | required |
| `Y1` | `y1` | `T` | derived | — | Second output tensor slice. | required |
| `Y2` | `y2` | `T` | derived | — | Third output tensor slice. | optional |
| `Y3` | `y3` | `T` | derived | — | Fourth output tensor slice. | optional |
| `Y4` | `y4` | `T` | derived | — | Fifth output tensor slice. | optional |
| `Y5` | `y5` | `T` | derived | — | Sixth output tensor slice. | optional |
## 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`, `bool` |
| `S` | `uint32` |
## Files
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, provenance)
- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
- [`test.json`](build/webgpu/test.json) — correctness cases
- [`bench.json`](build/webgpu/bench.json) — benchmark + tuning cases
- [`split-to-sequence.wgsl.jinja`](build/webgpu/split-to-sequence.wgsl.jinja)
## 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:
- `y0`
- `y1`
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.
```js
import { getKernel } from "@huggingface/kernels";
const kernel = await getKernel("webgpu-kernels/ai.onnx.SplitToSequence", { version: 1 });
// Explicit destinations request optional results or supply metadata that cannot be inferred.
const { y0, y1 } = await kernel({ input: { data: inputData, shape: [3, 2] } }, {
outputs: {
y0: { shape: [1, 2], dtype: "float32" },
y1: { shape: [1, 2], dtype: "float32" },
},
});
```