sync 2e7068faf55e
Browse files- README.md +66 -0
- build/webgpu/bench.json +49 -0
- build/webgpu/manifest.json +114 -0
- build/webgpu/metadata.json +18 -0
- build/webgpu/space-depth-permute.wgsl.jinja +80 -0
- build/webgpu/test.json +361 -0
README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: kernels
|
| 3 |
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- kernel
|
| 6 |
+
- webgpu
|
| 7 |
+
- wgsl
|
| 8 |
---
|
| 9 |
+
# ai.onnx.SpaceToDepth
|
| 10 |
+
|
| 11 |
+
`ai.onnx` · standard ONNX operator · ONNX opset ≥ 13
|
| 12 |
+
|
| 13 |
+
## Description
|
| 14 |
+
|
| 15 |
+
Rearranges blocks of spatial data into depth by moving values from the height and width dimensions into the channel dimension. An NCHW input of shape `[N, C, H, W]` produces an output of shape `[N, C * blocksize * blocksize, H / blocksize, W / blocksize]`.
|
| 16 |
+
|
| 17 |
+
See the [ONNX `SpaceToDepth` spec](https://onnx.ai/onnx/operators/onnx__SpaceToDepth.html) for the reference semantics.
|
| 18 |
+
|
| 19 |
+
## Inputs
|
| 20 |
+
|
| 21 |
+
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|
| 22 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 23 |
+
| `input` | `input` | `T` | `4` | — | 4-D input tensor of shape `[N, C, H, W]`. | required |
|
| 24 |
+
|
| 25 |
+
## Outputs
|
| 26 |
+
|
| 27 |
+
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|
| 28 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 29 |
+
| `output` | `output` | `T` | `4` | derived; see description | 4-D output tensor of shape `[N, C * blocksize * blocksize, H / blocksize, W / blocksize]`. | required |
|
| 30 |
+
|
| 31 |
+
## Attributes
|
| 32 |
+
|
| 33 |
+
Attributes and default values (overridable per request):
|
| 34 |
+
|
| 35 |
+
| Attribute | Default | Description |
|
| 36 |
+
| --- | --- | --- |
|
| 37 |
+
| `blocksize` | — | Size of the spatial block to collapse into depth; each `blocksize x blocksize` patch of pixels becomes additional channels. |
|
| 38 |
+
|
| 39 |
+
## Type constraints
|
| 40 |
+
|
| 41 |
+
| Variable | Allowed dtypes |
|
| 42 |
+
| --- | --- |
|
| 43 |
+
| `T` | `float32`, `float16`, `int32`, `int16`, `int8`, `uint32`, `uint8`, `bool` |
|
| 44 |
+
|
| 45 |
+
## Files
|
| 46 |
+
|
| 47 |
+
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, provenance)
|
| 48 |
+
- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
|
| 49 |
+
- [`test.json`](build/webgpu/test.json) — correctness cases
|
| 50 |
+
- [`bench.json`](build/webgpu/bench.json) — benchmark + tuning cases
|
| 51 |
+
- [`space-depth-permute.wgsl.jinja`](build/webgpu/space-depth-permute.wgsl.jinja)
|
| 52 |
+
|
| 53 |
+
## Use with `@huggingface/kernels`
|
| 54 |
+
|
| 55 |
+
The loader derives every required output's shape and logical dtype from the manifest contract and this call.
|
| 56 |
+
It then allocates the result tensors automatically.
|
| 57 |
+
|
| 58 |
+
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 59 |
+
|
| 60 |
+
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
|
| 61 |
+
|
| 62 |
+
```js
|
| 63 |
+
import { getKernel } from "@huggingface/kernels";
|
| 64 |
+
|
| 65 |
+
const kernel = await getKernel("webgpu-kernels/ai.onnx.SpaceToDepth", { version: 1 });
|
| 66 |
+
const { output } = await kernel({ input: { data: inputData, shape: [1, 1, 2, 4] } }, {
|
| 67 |
+
attrs: { blocksize: 2 },
|
| 68 |
+
});
|
| 69 |
+
```
|
build/webgpu/bench.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"op": "ai.onnx.SpaceToDepth",
|
| 3 |
+
"cases": [
|
| 4 |
+
{
|
| 5 |
+
"name": "nchw_1x64x128x128",
|
| 6 |
+
"attrs": { "blocksize": 2 },
|
| 7 |
+
"inputs": { "input": { "dtype": "float32", "shape": [1, 64, 128, 128] } },
|
| 8 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 256, 64, 64] } }
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"name": "nchw_1x32x192x192_block3",
|
| 12 |
+
"attrs": { "blocksize": 3 },
|
| 13 |
+
"inputs": { "input": { "dtype": "float32", "shape": [1, 32, 192, 192] } },
|
| 14 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 288, 64, 64] } }
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"name": "nchw_f16_1x64x128x128",
|
| 18 |
+
"preset": "smoke",
|
| 19 |
+
"attrs": { "blocksize": 2 },
|
| 20 |
+
"vars": { "dtype": "float16", "count": 1048576 },
|
| 21 |
+
"inputs": {
|
| 22 |
+
"input": { "dtype": "float16", "shape": [1, 64, 128, 128], "dist": "normal", "seed": 4471, "scale": 1 }
|
| 23 |
+
},
|
| 24 |
+
"outputs": { "output": { "dtype": "float16", "shape": [1, 256, 64, 64] } },
|
| 25 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"name": "nchw_dispatch_cliff_1x4194241x2x2",
|
| 29 |
+
"attrs": { "blocksize": 2 },
|
| 30 |
+
"vars": { "dtype": "float32", "count": 16776964 },
|
| 31 |
+
"inputs": {
|
| 32 |
+
"input": { "dtype": "float32", "shape": [1, 4194241, 2, 2], "dist": "normal", "seed": 4472, "scale": 1 }
|
| 33 |
+
},
|
| 34 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 16776964, 1, 1] } },
|
| 35 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"name": "nchw-const-fallback-odd-width-block2-f32-1x128x2048x6",
|
| 39 |
+
"preset": "stress",
|
| 40 |
+
"attrs": { "blocksize": 2 },
|
| 41 |
+
"vars": { "dtype": "float32", "count": 1572864 },
|
| 42 |
+
"inputs": {
|
| 43 |
+
"input": { "dtype": "float32", "shape": [1, 128, 2048, 6], "dist": "normal", "seed": 5201, "scale": 1 }
|
| 44 |
+
},
|
| 45 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 512, 1024, 3] } },
|
| 46 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 47 |
+
}
|
| 48 |
+
]
|
| 49 |
+
}
|
build/webgpu/manifest.json
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"domain": "ai.onnx",
|
| 3 |
+
"name": "SpaceToDepth",
|
| 4 |
+
"sinceVersion": 13,
|
| 5 |
+
"description": "Rearranges blocks of spatial data into depth by moving values from the height and width dimensions into the channel dimension. An NCHW input of shape `[N, C, H, W]` produces an output of shape `[N, C * blocksize * blocksize, H / blocksize, W / blocksize]`.",
|
| 6 |
+
"inputs": [{ "role": "input", "dtype": "T", "rank": 4, "description": "4-D input tensor of shape `[N, C, H, W]`." }],
|
| 7 |
+
"outputs": [
|
| 8 |
+
{
|
| 9 |
+
"role": "output",
|
| 10 |
+
"dtype": "T",
|
| 11 |
+
"rank": 4,
|
| 12 |
+
"description": "4-D output tensor of shape `[N, C * blocksize * blocksize, H / blocksize, W / blocksize]`.",
|
| 13 |
+
"shape": ["dim(shapes.input, 0)", "dim(shapes.input, 1) * attrs.blocksize * attrs.blocksize", "dim(shapes.input, 2) / attrs.blocksize", "dim(shapes.input, 3) / attrs.blocksize"]
|
| 14 |
+
}
|
| 15 |
+
],
|
| 16 |
+
"attributes": {},
|
| 17 |
+
"attributeDescriptions": {
|
| 18 |
+
"blocksize": "Size of the spatial block to collapse into depth; each `blocksize x blocksize` patch of pixels becomes additional channels."
|
| 19 |
+
},
|
| 20 |
+
"attributeConstraints": { "blocksize": { "required": true } },
|
| 21 |
+
"typeConstraints": { "T": ["float32", "float16", "int32", "int16", "int8", "uint32", "uint8", "bool"] },
|
| 22 |
+
"args": {
|
| 23 |
+
"input": { "kind": "tensor", "semantic": "input", "role": "input" },
|
| 24 |
+
"output": { "kind": "tensor", "semantic": "output", "role": "output" }
|
| 25 |
+
},
|
| 26 |
+
"tunables": { "WORKGROUP_SIZE": 256 },
|
| 27 |
+
"derive": {
|
| 28 |
+
"shapeContract": "attrs.blocksize > 0 and ranks.input == 4 and ranks.output == 4 and dim(shapes.output, 0) == dim(shapes.input, 0) and dim(shapes.output, 1) == dim(shapes.input, 1) * attrs.blocksize * attrs.blocksize and dim(shapes.output, 2) * attrs.blocksize == dim(shapes.input, 2) and dim(shapes.output, 3) * attrs.blocksize == dim(shapes.input, 3) and f16Ok(dtypes.T)",
|
| 29 |
+
"reportedWideExecution": "has(device.adapterInfo, \"subgroupMinSize\") and device.adapterInfo.subgroupMinSize >= 32",
|
| 30 |
+
"f16VectorPermutationPreferred": "dtypes.T != \"f16\" or device.features.has(\"subgroups\") or reportedWideExecution"
|
| 31 |
+
},
|
| 32 |
+
"constants": { "scalar": "dtypes.T", "usesF16": "dtypes.T == \"f16\"" },
|
| 33 |
+
"bindingSets": {
|
| 34 |
+
"io": [
|
| 35 |
+
{
|
| 36 |
+
"name": "input",
|
| 37 |
+
"arg": "input",
|
| 38 |
+
"semantic": "input",
|
| 39 |
+
"buffer": { "type": "read-only-storage" },
|
| 40 |
+
"elementType": "$scalar"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"name": "output",
|
| 44 |
+
"arg": "output",
|
| 45 |
+
"semantic": "output",
|
| 46 |
+
"buffer": { "type": "storage" },
|
| 47 |
+
"elementType": "$outputElement"
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
},
|
| 51 |
+
"variants": [
|
| 52 |
+
{
|
| 53 |
+
"id": "nchw_vec4",
|
| 54 |
+
"priority": 20,
|
| 55 |
+
"when": ["shapeContract", "dim(shapes.output, 3) % 4 == 0", "f16VectorPermutationPreferred"],
|
| 56 |
+
"constants": { "outputElement": "\"vec4<\" ~ dtypes.T ~ \">\"", "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" },
|
| 57 |
+
"passes": [
|
| 58 |
+
{
|
| 59 |
+
"id": "main",
|
| 60 |
+
"name": "SpaceToDepth",
|
| 61 |
+
"source": {
|
| 62 |
+
"shader": "space-depth-permute.wgsl.jinja",
|
| 63 |
+
"inputs": {
|
| 64 |
+
"direction": "\"spaceToDepth\"",
|
| 65 |
+
"mode": "\"DCR\"",
|
| 66 |
+
"vectorized": true,
|
| 67 |
+
"blocksize": "attrs.blocksize",
|
| 68 |
+
"count": "numel(shapes.output) / 4",
|
| 69 |
+
"outWUnits": "dim(shapes.output, 3) / 4",
|
| 70 |
+
"outH": "dim(shapes.output, 2)",
|
| 71 |
+
"outC": "dim(shapes.output, 1)",
|
| 72 |
+
"inC": "dim(shapes.input, 1)",
|
| 73 |
+
"inH": "dim(shapes.input, 2)",
|
| 74 |
+
"inW": "dim(shapes.input, 3)"
|
| 75 |
+
}
|
| 76 |
+
},
|
| 77 |
+
"bindings": "io",
|
| 78 |
+
"dispatch": { "threads": "numel(shapes.output) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 79 |
+
}
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"id": "nchw_const",
|
| 84 |
+
"priority": 10,
|
| 85 |
+
"when": ["shapeContract"],
|
| 86 |
+
"constants": { "outputElement": "dtypes.T" },
|
| 87 |
+
"passes": [
|
| 88 |
+
{
|
| 89 |
+
"id": "main",
|
| 90 |
+
"name": "SpaceToDepth",
|
| 91 |
+
"source": {
|
| 92 |
+
"shader": "space-depth-permute.wgsl.jinja",
|
| 93 |
+
"inputs": {
|
| 94 |
+
"direction": "\"spaceToDepth\"",
|
| 95 |
+
"mode": "\"DCR\"",
|
| 96 |
+
"vectorized": false,
|
| 97 |
+
"blocksize": "attrs.blocksize",
|
| 98 |
+
"count": "numel(shapes.output)",
|
| 99 |
+
"outWUnits": "dim(shapes.output, 3)",
|
| 100 |
+
"outW": "dim(shapes.output, 3)",
|
| 101 |
+
"outH": "dim(shapes.output, 2)",
|
| 102 |
+
"outC": "dim(shapes.output, 1)",
|
| 103 |
+
"inC": "dim(shapes.input, 1)",
|
| 104 |
+
"inH": "dim(shapes.input, 2)",
|
| 105 |
+
"inW": "dim(shapes.input, 3)"
|
| 106 |
+
}
|
| 107 |
+
},
|
| 108 |
+
"bindings": "io",
|
| 109 |
+
"dispatch": { "threads": "numel(shapes.output)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 110 |
+
}
|
| 111 |
+
]
|
| 112 |
+
}
|
| 113 |
+
]
|
| 114 |
+
}
|
build/webgpu/metadata.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "ai.onnx.SpaceToDepth",
|
| 3 |
+
"id": "_ai_onnx_spacetodepth_webgpu_cbf603a",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"backend": { "type": "webgpu" },
|
| 7 |
+
"digest": {
|
| 8 |
+
"algorithm": "sha256",
|
| 9 |
+
"files": {
|
| 10 |
+
"bench.json": "oDNgQ+aqxMurIw6vhcAUnPq8eIWuPYweL5P+hSxQqa8=",
|
| 11 |
+
"manifest.json": "XHyEI7bli7+h03YIu3a1rT9KFb1RBsgXhYWECC76yO4=",
|
| 12 |
+
"space-depth-permute.wgsl.jinja": "KbYVOfLYDd2L7BSJvB0dQYoKUYbQfHqvrzN+VJbkqew=",
|
| 13 |
+
"test.json": "IvLVrset+vkCY0gRqAbD44jO6hGRKbFHvti1sRY8iKo="
|
| 14 |
+
}
|
| 15 |
+
},
|
| 16 |
+
"provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } },
|
| 17 |
+
"webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/ai.onnx.SpaceToDepth" }
|
| 18 |
+
}
|
build/webgpu/space-depth-permute.wgsl.jinja
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}
|
| 2 |
+
{% if note == "dispatch-limit" %}
|
| 3 |
+
// 2D-folded flat index: gid.y carries the high bits past the
|
| 4 |
+
// maxComputeWorkgroupsPerDimension dispatch limit (outputs > 16.7M elements).
|
| 5 |
+
{% elif note == "limit" %}
|
| 6 |
+
// 2D-folded flat index: gid.y carries the high bits past the
|
| 7 |
+
// maxComputeWorkgroupsPerDimension limit.
|
| 8 |
+
{% elif note == "device-axis" %}
|
| 9 |
+
// The flat dispatch is folded across x/y at the device's per-axis workgroup
|
| 10 |
+
// limit; gid.y carries the high portion of the output index.
|
| 11 |
+
{% elif note == "vec4-limit" %}
|
| 12 |
+
// 2D-folded flat vec4 index: gid.y carries the high bits past the
|
| 13 |
+
// maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills into y).
|
| 14 |
+
{% elif note == "element-limit" %}
|
| 15 |
+
// 2D-folded flat element index: gid.y carries the high bits past the
|
| 16 |
+
// maxComputeWorkgroupsPerDimension limit.
|
| 17 |
+
{% elif note == "dispatch" %}
|
| 18 |
+
// 2D-folded flat index: gid.y carries the high bits past the
|
| 19 |
+
// maxComputeWorkgroupsPerDimension dispatch limit.
|
| 20 |
+
{% endif %}
|
| 21 |
+
{% if bound == "" %}
|
| 22 |
+
let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
|
| 23 |
+
{%- elif guardInline %}
|
| 24 |
+
let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
|
| 25 |
+
if ({{ name }} >= {{ bound }}) { return; }
|
| 26 |
+
{%- else %}
|
| 27 |
+
let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
|
| 28 |
+
if ({{ name }} >= {{ bound }}) {
|
| 29 |
+
return;
|
| 30 |
+
}
|
| 31 |
+
{%- endif %}
|
| 32 |
+
{% endmacro %}
|
| 33 |
+
|
| 34 |
+
{% if usesF16 %}
|
| 35 |
+
enable f16;
|
| 36 |
+
{% endif %}
|
| 37 |
+
{{ env.wgsl.resourceDeclarations }}
|
| 38 |
+
|
| 39 |
+
// Specializing all geometry lets division and modulo lower to constant
|
| 40 |
+
// multiply-high/shift sequences. max(1) keeps zero-sized tensors compilable;
|
| 41 |
+
// they dispatch no work.
|
| 42 |
+
const COUNT: u32 = {{ source.count }}u;
|
| 43 |
+
const OUT_W_UNITS: u32 = max(1u, {{ source.outWUnits }}u);
|
| 44 |
+
const OUT_H: u32 = max(1u, {{ source.outH }}u);
|
| 45 |
+
const OUT_C: u32 = max(1u, {{ source.outC }}u);
|
| 46 |
+
const IN_C: u32 = max(1u, {{ source.inC }}u);
|
| 47 |
+
const IN_H: u32 = {{ source.inH }}u;
|
| 48 |
+
const IN_W: u32 = {{ source.inW }}u;
|
| 49 |
+
const BLOCK_SIZE: u32 = {{ source.blocksize }}u;
|
| 50 |
+
|
| 51 |
+
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
|
| 52 |
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
|
| 53 |
+
{{ flat_index_2d("out_unit", "COUNT", note="") }}
|
| 54 |
+
|
| 55 |
+
let ow_unit = out_unit % OUT_W_UNITS;
|
| 56 |
+
var remaining = out_unit / OUT_W_UNITS;
|
| 57 |
+
let oh = remaining % OUT_H;
|
| 58 |
+
remaining /= OUT_H;
|
| 59 |
+
let oc = remaining % OUT_C;
|
| 60 |
+
let n = remaining / OUT_C;
|
| 61 |
+
let ow_base = ow_unit * {{ 4 if source.vectorized else 1 }}u;
|
| 62 |
+
|
| 63 |
+
let c = oc % IN_C;
|
| 64 |
+
let block = oc / IN_C;
|
| 65 |
+
let bh = block / BLOCK_SIZE;
|
| 66 |
+
let bw = block % BLOCK_SIZE;
|
| 67 |
+
let ih = oh * BLOCK_SIZE + bh;
|
| 68 |
+
let input_base = ((n * IN_C + c) * IN_H + ih) * IN_W + bw;
|
| 69 |
+
|
| 70 |
+
{% for lane in range(4 if source.vectorized else 1) %}
|
| 71 |
+
let ow{{ lane }} = ow_base + {{ lane }}u;
|
| 72 |
+
let value{{ lane }} = input[input_base + ow{{ lane }} * BLOCK_SIZE];
|
| 73 |
+
{% endfor %}
|
| 74 |
+
|
| 75 |
+
{% if source.vectorized %}
|
| 76 |
+
output[out_unit] = {{ vectorScalar }}(value0, value1, value2, value3);
|
| 77 |
+
{% else %}
|
| 78 |
+
output[out_unit] = value0;
|
| 79 |
+
{% endif %}
|
| 80 |
+
}
|
build/webgpu/test.json
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"op": "ai.onnx.SpaceToDepth",
|
| 3 |
+
"fixtureArrays": {
|
| 4 |
+
"onnx_backend_example_1x1x4x6_input_input": [0, 6, 1, 7, 2, 8, 12, 18, 13, 19, 14, 20, 3, 9, 4, 10, 5, 11, 15, 21, 16, 22, 17, 23]
|
| 5 |
+
},
|
| 6 |
+
"cases": [
|
| 7 |
+
{
|
| 8 |
+
"name": "dispatch_cliff_nchw_channel_heavy",
|
| 9 |
+
"attrs": { "blocksize": 2 },
|
| 10 |
+
"inputs": {
|
| 11 |
+
"input": {
|
| 12 |
+
"dtype": "float32",
|
| 13 |
+
"shape": [1, 4194241, 2, 2],
|
| 14 |
+
"data": { "kind": "linspace", "start": 0.0, "end": 1.0 }
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 16776964, 1, 1], "tolerance": 0 } }
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"name": "nchw",
|
| 21 |
+
"attrs": { "blocksize": 2 },
|
| 22 |
+
"inputs": {
|
| 23 |
+
"input": {
|
| 24 |
+
"dtype": "float32",
|
| 25 |
+
"shape": [1, 1, 4, 4],
|
| 26 |
+
"data": {
|
| 27 |
+
"kind": "values",
|
| 28 |
+
"values": [0.0, 10.0, 1.0, 11.0, 20.0, 30.0, 21.0, 31.0, 2.0, 12.0, 3.0, 13.0, 22.0, 32.0, 23.0, 33.0]
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 4, 2, 2] } }
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"name": "nchw_block3_multichannel",
|
| 36 |
+
"attrs": { "blocksize": 3 },
|
| 37 |
+
"inputs": {
|
| 38 |
+
"input": {
|
| 39 |
+
"dtype": "float32",
|
| 40 |
+
"shape": [1, 2, 6, 3],
|
| 41 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.29 }
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 18, 2, 1] } }
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"name": "nchw_f16_batch2_block2",
|
| 48 |
+
"attrs": { "blocksize": 2 },
|
| 49 |
+
"inputs": {
|
| 50 |
+
"input": {
|
| 51 |
+
"dtype": "float16",
|
| 52 |
+
"shape": [2, 1, 2, 2],
|
| 53 |
+
"data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, -1.0, -2.0, -3.0, -4.0] }
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"outputs": { "output": { "dtype": "float16", "shape": [2, 4, 1, 1], "tolerance": 0 } }
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"name": "empty_zero_height_block2",
|
| 60 |
+
"attrs": { "blocksize": 2 },
|
| 61 |
+
"inputs": { "input": { "dtype": "float32", "shape": [1, 1, 0, 4] } },
|
| 62 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 4, 0, 2], "tolerance": 0 } }
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"name": "onnx_backend_example_1x1x4x6",
|
| 66 |
+
"attrs": { "blocksize": 2 },
|
| 67 |
+
"inputs": {
|
| 68 |
+
"input": {
|
| 69 |
+
"dtype": "float32",
|
| 70 |
+
"shape": [1, 1, 4, 6],
|
| 71 |
+
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_example_1x1x4x6_input_input" } }
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 4, 2, 3], "tolerance": 0 } }
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"name": "ort_block2_two_channels_wide",
|
| 78 |
+
"attrs": { "blocksize": 2 },
|
| 79 |
+
"provenance": {
|
| 80 |
+
"source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc",
|
| 81 |
+
"test": "TensorOpTest.SpaceToDepthTest_1"
|
| 82 |
+
},
|
| 83 |
+
"inputs": {
|
| 84 |
+
"input": {
|
| 85 |
+
"dtype": "float32",
|
| 86 |
+
"shape": [1, 2, 2, 4],
|
| 87 |
+
"data": {
|
| 88 |
+
"kind": "values",
|
| 89 |
+
"values": [0.0, 0.1, 0.2, 0.3, 1.0, 1.1, 1.2, 1.3, 2.0, 2.1, 2.2, 2.3, 3.0, 3.1, 3.2, 3.3]
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
},
|
| 93 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 8, 1, 2], "tolerance": 0.000001 } }
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"name": "ort_block2_two_channels_tall_and_wide",
|
| 97 |
+
"attrs": { "blocksize": 2 },
|
| 98 |
+
"provenance": {
|
| 99 |
+
"source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc",
|
| 100 |
+
"test": "TensorOpTest.SpaceToDepthTest_3"
|
| 101 |
+
},
|
| 102 |
+
"inputs": {
|
| 103 |
+
"input": {
|
| 104 |
+
"dtype": "float32",
|
| 105 |
+
"shape": [1, 2, 4, 8],
|
| 106 |
+
"data": {
|
| 107 |
+
"kind": "values",
|
| 108 |
+
"values": [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7]
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 8, 2, 4], "tolerance": 0.000001 } }
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"name": "f16_block3_single_pixel_output",
|
| 116 |
+
"attrs": { "blocksize": 3 },
|
| 117 |
+
"inputs": {
|
| 118 |
+
"input": {
|
| 119 |
+
"dtype": "float16",
|
| 120 |
+
"shape": [1, 1, 3, 3],
|
| 121 |
+
"data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] }
|
| 122 |
+
}
|
| 123 |
+
},
|
| 124 |
+
"outputs": { "output": { "dtype": "float16", "shape": [1, 9, 1, 1], "tolerance": 0 } }
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"name": "ort_block3_batch2_channels3",
|
| 128 |
+
"attrs": { "blocksize": 3 },
|
| 129 |
+
"provenance": {
|
| 130 |
+
"source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc",
|
| 131 |
+
"test": "TensorOpTest.SpaceToDepthTest_2",
|
| 132 |
+
"notes": "Uses the ORT shape/blocksize; fixture values are generated deterministically."
|
| 133 |
+
},
|
| 134 |
+
"inputs": {
|
| 135 |
+
"input": {
|
| 136 |
+
"dtype": "float32",
|
| 137 |
+
"shape": [2, 3, 3, 6],
|
| 138 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.01, "cosStep": 0.0, "scale": 100.0 }
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
"outputs": { "output": { "dtype": "float32", "shape": [2, 27, 1, 2], "tolerance": 0.000001 } }
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"name": "onnx_backend_spacetodepth",
|
| 145 |
+
"attrs": { "blocksize": 2 },
|
| 146 |
+
"inputs": {
|
| 147 |
+
"input": {
|
| 148 |
+
"dtype": "float32",
|
| 149 |
+
"shape": [2, 2, 6, 6],
|
| 150 |
+
"data": {
|
| 151 |
+
"kind": "values",
|
| 152 |
+
"values": [0.54881352186203, 0.7151893377304077, 0.6027633547782898, 0.5448831915855408, 0.42365479469299316, 0.6458941102027893, 0.4375872015953064, 0.891772985458374, 0.9636627435684204, 0.3834415078163147, 0.7917250394821167, 0.5288949012756348, 0.5680445432662964, 0.9255966544151306, 0.07103605568408966, 0.08712930232286453, 0.020218396559357643, 0.832619845867157, 0.7781567573547363, 0.8700121641159058, 0.978618323802948, 0.7991585731506348, 0.4614793658256531, 0.7805292010307312, 0.11827442795038223, 0.6399210095405579, 0.14335328340530396, 0.9446688890457153, 0.5218483209609985, 0.4146619439125061, 0.26455560326576233, 0.7742336988449097, 0.4561503231525421, 0.568433940410614, 0.018789799883961678, 0.6176354885101318, 0.6120957136154175, 0.6169340014457703, 0.9437480568885803, 0.681820273399353, 0.35950788855552673, 0.43703195452690125, 0.6976311802864075, 0.0602254718542099, 0.6667667031288147, 0.670637845993042, 0.21038256585597992, 0.12892629206180573, 0.31542834639549255, 0.36371076107025146, 0.5701967477798462, 0.4386015236377716, 0.9883738160133362, 0.10204481333494186, 0.20887675881385803, 0.16130951046943665, 0.6531082987785339, 0.25329160690307617, 0.4663107693195343, 0.24442559480667114, 0.15896958112716675, 0.11037514358758926, 0.6563295722007751, 0.13818295300006866, 0.1965823620557785, 0.3687251806259155, 0.8209932446479797, 0.09710127860307693, 0.8379449248313904, 0.0960984081029892, 0.9764594435691833, 0.4686512053012848, 0.9767611026763916, 0.6048455238342285, 0.7392635941505432, 0.03918779268860817, 0.28280696272850037, 0.12019655853509903, 0.296140193939209, 0.11872772127389908, 0.3179831802845001, 0.414262980222702, 0.06414749473333359, 0.6924721002578735, 0.5666014552116394, 0.26538950204849243, 0.5232480764389038, 0.09394051134586334, 0.5759465098381042, 0.9292961955070496, 0.3185689449310303, 0.6674103736877441, 0.13179786503314972, 0.7163271903991699, 0.28940609097480774, 0.18319135904312134, 0.5865129232406616, 0.02010754682123661, 0.8289400339126587, 0.004695476032793522, 0.6778165102005005, 0.2700079679489136, 0.7351940274238586, 0.9621885418891907, 0.2487531453371048, 0.5761573314666748, 0.5920419096946716, 0.5722519159317017, 0.22308163344860077, 0.9527490139007568, 0.4471253752708435, 0.8464086651802063, 0.6994792819023132, 0.2974369525909424, 0.8137978315353394, 0.396505743265152, 0.8811032176017761, 0.5812729001045227, 0.8817353844642639, 0.6925315856933594, 0.7252542972564697, 0.5013243556022644, 0.9560836553573608, 0.6439902186393738, 0.4238550364971161, 0.6063932180404663, 0.019193198531866074, 0.30157482624053955, 0.6601735353469849, 0.2900775969028473, 0.6180154085159302, 0.42876869440078735, 0.1354740709066391, 0.29828232526779175, 0.5699648857116699, 0.5908727645874023, 0.5743252635002136, 0.6532008051872253, 0.6521032452583313, 0.43141844868659973, 0.8965466022491455, 0.36756187677383423, 0.4358649253845215, 0.8919233679771423]
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
},
|
| 156 |
+
"outputs": { "output": { "dtype": "float32", "shape": [2, 8, 3, 3] } },
|
| 157 |
+
"provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_spacetodepth" }
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"name": "onnx_backend_spacetodepth_example",
|
| 161 |
+
"attrs": { "blocksize": 2 },
|
| 162 |
+
"inputs": {
|
| 163 |
+
"input": {
|
| 164 |
+
"dtype": "float32",
|
| 165 |
+
"shape": [1, 1, 4, 6],
|
| 166 |
+
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_example_1x1x4x6_input_input" } }
|
| 167 |
+
}
|
| 168 |
+
},
|
| 169 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 4, 2, 3] } },
|
| 170 |
+
"provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_spacetodepth_example" }
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"name": "empty_zero_dim",
|
| 174 |
+
"attrs": { "blocksize": 2 },
|
| 175 |
+
"inputs": { "input": { "dtype": "float32", "shape": [0, 1, 4, 4], "data": { "kind": "values", "values": [] } } },
|
| 176 |
+
"outputs": { "output": { "dtype": "float32", "shape": [0, 4, 2, 2], "tolerance": 0 } }
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"name": "empty_zero_dim_f16",
|
| 180 |
+
"attrs": { "blocksize": 2 },
|
| 181 |
+
"inputs": { "input": { "dtype": "float16", "shape": [0, 1, 4, 4], "data": { "kind": "values", "values": [] } } },
|
| 182 |
+
"outputs": { "output": { "dtype": "float16", "shape": [0, 4, 2, 2], "tolerance": 0 } }
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"name": "nchw_block4_multichannel",
|
| 186 |
+
"attrs": { "blocksize": 4 },
|
| 187 |
+
"inputs": {
|
| 188 |
+
"input": {
|
| 189 |
+
"dtype": "float32",
|
| 190 |
+
"shape": [1, 3, 8, 16],
|
| 191 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.13, "cosStep": 0.07 }
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 48, 2, 4], "tolerance": 0 } }
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"name": "nchw_block4_f16",
|
| 198 |
+
"attrs": { "blocksize": 4 },
|
| 199 |
+
"inputs": {
|
| 200 |
+
"input": {
|
| 201 |
+
"dtype": "float16",
|
| 202 |
+
"shape": [1, 2, 4, 16],
|
| 203 |
+
"data": {
|
| 204 |
+
"kind": "values",
|
| 205 |
+
"values": [-8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0]
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
},
|
| 209 |
+
"outputs": { "output": { "dtype": "float16", "shape": [1, 32, 1, 4], "tolerance": 0 } }
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"name": "nchw_block1_identity",
|
| 213 |
+
"attrs": { "blocksize": 1 },
|
| 214 |
+
"inputs": {
|
| 215 |
+
"input": {
|
| 216 |
+
"dtype": "float32",
|
| 217 |
+
"shape": [1, 2, 2, 4],
|
| 218 |
+
"data": {
|
| 219 |
+
"kind": "values",
|
| 220 |
+
"values": [-5.0, -3.5, -2.0, -0.5, 1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0, 11.5, 13.0, 14.5, 16.0, 17.5]
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
},
|
| 224 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 2, 2, 4], "tolerance": 0 } }
|
| 225 |
+
},
|
| 226 |
+
{
|
| 227 |
+
"name": "nchw_const_odd_width_block2_addressing",
|
| 228 |
+
"attrs": { "blocksize": 2 },
|
| 229 |
+
"inputs": {
|
| 230 |
+
"input": {
|
| 231 |
+
"dtype": "float32",
|
| 232 |
+
"shape": [1, 2, 4, 6],
|
| 233 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.09, "cosStep": 0.21 }
|
| 234 |
+
}
|
| 235 |
+
},
|
| 236 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 8, 2, 3], "tolerance": 0 } }
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"name": "nchw_const_block3_odd_width_multichannel",
|
| 240 |
+
"attrs": { "blocksize": 3 },
|
| 241 |
+
"inputs": {
|
| 242 |
+
"input": {
|
| 243 |
+
"dtype": "float32",
|
| 244 |
+
"shape": [1, 2, 6, 15],
|
| 245 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.05, "cosStep": 0.17 }
|
| 246 |
+
}
|
| 247 |
+
},
|
| 248 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 18, 2, 5], "tolerance": 0 } }
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"name": "nchw_vec4_block3_width_mul4_multichannel",
|
| 252 |
+
"attrs": { "blocksize": 3 },
|
| 253 |
+
"inputs": {
|
| 254 |
+
"input": {
|
| 255 |
+
"dtype": "float32",
|
| 256 |
+
"shape": [1, 2, 6, 12],
|
| 257 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.15, "cosStep": 0.11 }
|
| 258 |
+
}
|
| 259 |
+
},
|
| 260 |
+
"outputs": { "output": { "dtype": "float32", "shape": [1, 18, 2, 4], "tolerance": 0 } }
|
| 261 |
+
},
|
| 262 |
+
{
|
| 263 |
+
"name": "ort_standard_int32_block2_extremes",
|
| 264 |
+
"provenance": {
|
| 265 |
+
"source": "onnx/docs/Operators.md#SpaceToDepth",
|
| 266 |
+
"notes": "ONNX SpaceToDepth-13 permits int32; signed extrema prove the widened i32 route is a bit-exact permutation."
|
| 267 |
+
},
|
| 268 |
+
"attrs": { "blocksize": 2 },
|
| 269 |
+
"inputs": {
|
| 270 |
+
"input": {
|
| 271 |
+
"dtype": "int32",
|
| 272 |
+
"shape": [1, 1, 2, 4],
|
| 273 |
+
"data": { "kind": "values", "values": [-2147483648, 2147483647, -16777217, 16777217, -1, 0, 42, -42] }
|
| 274 |
+
}
|
| 275 |
+
},
|
| 276 |
+
"outputs": { "output": { "dtype": "int32", "shape": [1, 4, 1, 2], "tolerance": 0 } }
|
| 277 |
+
},
|
| 278 |
+
{
|
| 279 |
+
"name": "ort_standard_int16_block2_extremes",
|
| 280 |
+
"provenance": {
|
| 281 |
+
"source": "onnx/docs/Operators.md#SpaceToDepth",
|
| 282 |
+
"notes": "ONNX SpaceToDepth-13 permits int16; both signed extrema guard the runtime's widened i32 storage route."
|
| 283 |
+
},
|
| 284 |
+
"attrs": { "blocksize": 2 },
|
| 285 |
+
"inputs": {
|
| 286 |
+
"input": {
|
| 287 |
+
"dtype": "int16",
|
| 288 |
+
"shape": [1, 1, 2, 4],
|
| 289 |
+
"data": { "kind": "values", "values": [-32768, 32767, -12345, 12345, -1, 0, 42, -42] }
|
| 290 |
+
}
|
| 291 |
+
},
|
| 292 |
+
"outputs": { "output": { "dtype": "int16", "shape": [1, 4, 1, 2], "tolerance": 0 } }
|
| 293 |
+
},
|
| 294 |
+
{
|
| 295 |
+
"name": "ort_standard_int8_block2_extremes",
|
| 296 |
+
"provenance": {
|
| 297 |
+
"source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc",
|
| 298 |
+
"test": "TensorOpTest.SpaceToDepthTest_int_opset13",
|
| 299 |
+
"notes": "Uses both int8 extrema so the widened i32 storage route cannot hide narrowing or sign loss."
|
| 300 |
+
},
|
| 301 |
+
"attrs": { "blocksize": 2 },
|
| 302 |
+
"inputs": {
|
| 303 |
+
"input": {
|
| 304 |
+
"dtype": "int8",
|
| 305 |
+
"shape": [1, 1, 2, 4],
|
| 306 |
+
"data": { "kind": "values", "values": [-128, 127, -64, 63, -1, 0, 42, -42] }
|
| 307 |
+
}
|
| 308 |
+
},
|
| 309 |
+
"outputs": { "output": { "dtype": "int8", "shape": [1, 4, 1, 2], "tolerance": 0 } }
|
| 310 |
+
},
|
| 311 |
+
{
|
| 312 |
+
"name": "ort_standard_uint32_block2_extremes",
|
| 313 |
+
"provenance": {
|
| 314 |
+
"source": "onnx/docs/Operators.md#SpaceToDepth",
|
| 315 |
+
"notes": "ONNX SpaceToDepth-13 permits uint32; values across the signed boundary and UINT32_MAX guard exact u32 payload movement."
|
| 316 |
+
},
|
| 317 |
+
"attrs": { "blocksize": 2 },
|
| 318 |
+
"inputs": {
|
| 319 |
+
"input": {
|
| 320 |
+
"dtype": "uint32",
|
| 321 |
+
"shape": [1, 1, 2, 4],
|
| 322 |
+
"data": { "kind": "values", "values": [0, 4294967295, 16777217, 2147483648, 1, 42, 4000000000, 255] }
|
| 323 |
+
}
|
| 324 |
+
},
|
| 325 |
+
"outputs": { "output": { "dtype": "uint32", "shape": [1, 4, 1, 2], "tolerance": 0 } }
|
| 326 |
+
},
|
| 327 |
+
{
|
| 328 |
+
"name": "ort_standard_uint8_block2_extremes",
|
| 329 |
+
"provenance": {
|
| 330 |
+
"source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc",
|
| 331 |
+
"test": "TensorOpTest.SpaceToDepthTest_int_opset13",
|
| 332 |
+
"notes": "Includes UINT8_MAX and values around the signed boundary on the widened u32 storage route."
|
| 333 |
+
},
|
| 334 |
+
"attrs": { "blocksize": 2 },
|
| 335 |
+
"inputs": {
|
| 336 |
+
"input": {
|
| 337 |
+
"dtype": "uint8",
|
| 338 |
+
"shape": [1, 1, 2, 4],
|
| 339 |
+
"data": { "kind": "values", "values": [0, 255, 127, 128, 1, 42, 254, 64] }
|
| 340 |
+
}
|
| 341 |
+
},
|
| 342 |
+
"outputs": { "output": { "dtype": "uint8", "shape": [1, 4, 1, 2], "tolerance": 0 } }
|
| 343 |
+
},
|
| 344 |
+
{
|
| 345 |
+
"name": "ort_standard_bool_block2_pattern",
|
| 346 |
+
"provenance": {
|
| 347 |
+
"source": "onnx/docs/Operators.md#SpaceToDepth",
|
| 348 |
+
"notes": "ONNX SpaceToDepth-13 permits bool; an asymmetric pattern checks that widened u32 boolean payloads are reordered without conversion."
|
| 349 |
+
},
|
| 350 |
+
"attrs": { "blocksize": 2 },
|
| 351 |
+
"inputs": {
|
| 352 |
+
"input": {
|
| 353 |
+
"dtype": "bool",
|
| 354 |
+
"shape": [1, 1, 2, 4],
|
| 355 |
+
"data": { "kind": "values", "values": [0, 1, 1, 0, 1, 1, 0, 0] }
|
| 356 |
+
}
|
| 357 |
+
},
|
| 358 |
+
"outputs": { "output": { "dtype": "bool", "shape": [1, 4, 1, 2], "tolerance": 0 } }
|
| 359 |
+
}
|
| 360 |
+
]
|
| 361 |
+
}
|