sync 2e7068faf55e
Browse filesFiles changed (7)
- README.md+68
- build/webgpu/bench.jsonAdded+69
- build/webgpu/depth-to-space-nchw-coarsened4.wgsl.jinjaAdded+52
- build/webgpu/manifest.jsonAdded+145
- build/webgpu/metadata.jsonAdded+19
- build/webgpu/space-depth-permute.wgsl.jinjaAdded+81
- build/webgpu/test.jsonAdded+592
123---license: apache-2.0---1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071---library_name: kernelslicense: apache-2.0tags:- kernel- webgpu- wgsl---# ai.onnx.DepthToSpace`ai.onnx` · standard ONNX operator · ONNX opset ≥ 13## DescriptionRearranges data from the depth dimension into spatial blocks, expanding height and width by `blocksize` while reducing channels by `blocksize * blocksize`. The inverse of SpaceToDepth; supports `DCR` (depth-column-row) and `CRD` (column-row-depth) element orderings.See the [ONNX `DepthToSpace` spec](https://onnx.ai/onnx/operators/onnx__DepthToSpace.html) for the reference semantics.## Inputs| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence || --- | --- | --- | --- | --- | --- | --- || `input` | `input` | `T` | `4` | — | 4-D input tensor of shape `[N, C, H, W]`. | required |## Outputs| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence || --- | --- | --- | --- | --- | --- | --- || `output` | `output` | `T` | `4` | derived; see description | 4-D output tensor of shape `[N, C/(blocksize*blocksize), H*blocksize, W*blocksize]`. | required |## AttributesAttributes and default values (overridable per request):| Attribute | Default | Description || --- | --- | --- || `mode` | `"DCR"` | Element ordering within each block: `DCR`, the default depth-column-row order, or `CRD`, the column-row-depth order. || `blocksize` | — | Side length of the spatial blocks; input channels are divided by `blocksize * blocksize`. |## Type constraints| Variable | Allowed dtypes || --- | --- || `T` | `float32`, `float16`, `int32`, `int16`, `int8`, `uint32`, `uint8`, `bool` |## 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- [`depth-to-space-nchw-coarsened4.wgsl.jinja`](build/webgpu/depth-to-space-nchw-coarsened4.wgsl.jinja)- [`space-depth-permute.wgsl.jinja`](build/webgpu/space-depth-permute.wgsl.jinja)## Use with `@huggingface/kernels`The loader derives every required output's shape and logical dtype from the manifest contract and this call.It then allocates the result tensors automatically.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.```jsimport { getKernel } from "@huggingface/kernels";const kernel = await getKernel("webgpu-kernels/ai.onnx.DepthToSpace", { version: 1 });const { output } = await kernel({ input: { data: inputData, shape: [1, 8, 1, 1] } }, {attrs: { blocksize: 2 },});```
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869{ "op": "ai.onnx.DepthToSpace", "cases": [ { "name": "nchw_1x256x64x64", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 256, 64, 64] } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 64, 128, 128] } } }, { "name": "nchw_1x256x64x64_crd", "attrs": { "blocksize": 2, "mode": "CRD" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 256, 64, 64] } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 64, 128, 128] } } }, { "name": "depthtospace-f16-1x256x64x64", "preset": "smoke", "attrs": { "blocksize": 2, "mode": "DCR" }, "vars": { "dtype": "float16", "count": 1048576 }, "inputs": { "input": { "dtype": "float16", "shape": [1, 256, 64, 64] } }, "outputs": { "output": { "dtype": "float16", "shape": [1, 64, 128, 128] } }, "bench": { "primary": true, "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] } }, { "name": "depthtospace-dispatch-cliff-scalar-f32", "attrs": { "blocksize": 2, "mode": "DCR" }, "vars": { "dtype": "float32", "count": 16785408 }, "inputs": { "input": { "dtype": "float32", "shape": [1, 4, 2048, 2049] } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 4096, 4098] } }, "bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] } }, { "name": "depthtospace-crd-1x256x64x64-f32", "attrs": { "blocksize": 2, "mode": "CRD" }, "vars": { "dtype": "float32", "count": 1048576 }, "inputs": { "input": { "dtype": "float32", "shape": [1, 256, 64, 64] } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 64, 128, 128] } }, "bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] } }, { "name": "blocksize3_scalar_path_large_dcr", "preset": "stress", "attrs": { "blocksize": 3, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 9, 2048, 682], "dist": "normal", "seed": 421, "scale": 1 } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 6144, 2046] } }, "bench": { "metrics": [{ "type": "bandwidth", "value": "12570624 * 4 * 2" }] } }, { "name": "blocksize3-odd-width-f32-b1c576-171x129-super-resolution", "preset": "stress", "attrs": { "blocksize": 3, "mode": "DCR" }, "vars": { "dtype": "float32", "count": 12707712 }, "inputs": { "input": { "dtype": "float32", "shape": [1, 576, 171, 129], "dist": "normal", "seed": 422, "scale": 1 } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 64, 513, 387] } }, "bench": { "primary": true, "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] } } ]}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152{% if usesF16 %}enable f16;{% endif %}{{ env.wgsl.resourceDeclarations }}
// Four adjacent output columns share N/C/H decoding and the block-row lookup.// Keeping scalar bindings makes this valid for odd output widths; only the last// group in each row is predicated. Static dimensions let the shader compiler// eliminate all division and modulo operations.const GROUPS: u32 = {{ source.groups }}u;const OUT_W_GROUPS: u32 = max(1u, {{ source.outWGroups }}u);const OUT_W: u32 = max(1u, {{ source.outW }}u);const OUT_H: u32 = max(1u, {{ source.outH }}u);const OUT_C: u32 = max(1u, {{ source.outC }}u);const IN_C: u32 = {{ source.inC }}u;const IN_H: u32 = {{ source.inH }}u;const IN_W: u32 = {{ source.inW }}u;const BS: u32 = {{ source.blocksize }}u;const WG: u32 = {{ tunables.WORKGROUP_SIZE }}u;
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) { let q = gid.x + gid.y * nwg.x * WG; if (q >= GROUPS) { return; }
let owBase = (q % OUT_W_GROUPS) * 4u; var t = q / OUT_W_GROUPS; let oh = t % OUT_H; t /= OUT_H; let oc = t % OUT_C; let n = t / OUT_C; let bh = oh % BS; let ih = oh / BS;
{% for k in range(4) %} { let ow = owBase + {{ k }}u; if (ow < OUT_W) { let bw = ow % BS; let iw = ow / BS;{% if source.mode == "CRD" %} let ic = (oc * BS + bh) * BS + bw;{% else %} let ic = (bh * BS + bw) * OUT_C + oc;{% endif %} let outIndex = ((n * OUT_C + oc) * OUT_H + oh) * OUT_W + ow; let inIndex = ((n * IN_C + ic) * IN_H + ih) * IN_W + iw; output[outIndex] = input[inIndex]; } }{% endfor %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145{ "domain": "ai.onnx", "name": "DepthToSpace", "sinceVersion": 13, "description": "Rearranges data from the depth dimension into spatial blocks, expanding height and width by `blocksize` while reducing channels by `blocksize * blocksize`. The inverse of SpaceToDepth; supports `DCR` (depth-column-row) and `CRD` (column-row-depth) element orderings.", "inputs": [{ "role": "input", "dtype": "T", "rank": 4, "description": "4-D input tensor of shape `[N, C, H, W]`." }], "outputs": [ { "role": "output", "dtype": "T", "rank": 4, "description": "4-D output tensor of shape `[N, C/(blocksize*blocksize), H*blocksize, W*blocksize]`.", "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"] } ], "attributes": { "mode": "DCR" }, "attributeDescriptions": { "blocksize": "Side length of the spatial blocks; input channels are divided by `blocksize * blocksize`.", "mode": "Element ordering within each block: `DCR`, the default depth-column-row order, or `CRD`, the column-row-depth order." }, "attributeConstraints": { "blocksize": { "required": true }, "mode": { "values": ["DCR", "CRD"] } }, "typeConstraints": { "T": ["float32", "float16", "int32", "int16", "int8", "uint32", "uint8", "bool"] }, "args": { "input": { "kind": "tensor", "semantic": "input", "role": "input" }, "output": { "kind": "tensor", "semantic": "output", "role": "output" } }, "tunables": { "WORKGROUP_SIZE": 256 }, "derive": { "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) * attrs.blocksize * attrs.blocksize == dim(shapes.input, 1) and dim(shapes.output, 2) == dim(shapes.input, 2) * attrs.blocksize and dim(shapes.output, 3) == dim(shapes.input, 3) * attrs.blocksize and f16Ok(dtypes.T)" }, "constants": { "scalar": "dtypes.T", "usesF16": "dtypes.T == \"f16\"" }, "bindingSets": { "io": [ { "name": "input", "arg": "input", "semantic": "input", "buffer": { "type": "read-only-storage" }, "elementType": "$scalar" }, { "name": "output", "arg": "output", "semantic": "output", "buffer": { "type": "storage" }, "elementType": "$outputElement" } ] }, "variants": [ { "id": "nchw_vec4", "priority": 20, "when": ["shapeContract", "dim(shapes.output, 3) % 4 == 0"], "constants": { "outputElement": "\"vec4<\" ~ dtypes.T ~ \">\"", "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" }, "passes": [ { "id": "main", "name": "DepthToSpace", "source": { "shader": "space-depth-permute.wgsl.jinja", "inputs": { "direction": "\"depthToSpace\"", "mode": "attrs.mode", "vectorized": true, "blocksize": "attrs.blocksize", "count": "numel(shapes.output) / 4", "outWUnits": "dim(shapes.output, 3) / 4", "outH": "dim(shapes.output, 2)", "outC": "dim(shapes.output, 1)", "inC": "dim(shapes.input, 1)", "inH": "dim(shapes.input, 2)", "inW": "dim(shapes.input, 3)" } }, "bindings": "io", "dispatch": { "threads": "numel(shapes.output) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" } } ] }, { "id": "nchw_const", "priority": 10, "when": ["shapeContract"], "constants": { "outputElement": "dtypes.T" }, "passes": [ { "id": "main", "name": "DepthToSpace", "source": { "shader": "space-depth-permute.wgsl.jinja", "inputs": { "direction": "\"depthToSpace\"", "mode": "attrs.mode", "vectorized": false, "blocksize": "attrs.blocksize", "count": "numel(shapes.output)", "outWUnits": "dim(shapes.output, 3)", "outC": "dim(shapes.output, 1)", "outH": "dim(shapes.output, 2)", "outW": "dim(shapes.output, 3)", "inC": "dim(shapes.input, 1)", "inH": "dim(shapes.input, 2)", "inW": "dim(shapes.input, 3)" } }, "bindings": "io", "dispatch": { "threads": "numel(shapes.output)", "workgroupSize": "tunables.WORKGROUP_SIZE" } } ] }, { "id": "nchw_coarsened4", "priority": 15, "when": ["shapeContract", "dim(shapes.output, 3) % 4 != 0", "numel(shapes.output) >= 4096"], "constants": { "outputElement": "dtypes.T" }, "passes": [ { "id": "main", "name": "DepthToSpace.Coarsened4", "source": { "shader": "depth-to-space-nchw-coarsened4.wgsl.jinja", "inputs": { "mode": "attrs.mode", "blocksize": "attrs.blocksize", "groups": "dim(shapes.output, 0) * dim(shapes.output, 1) * dim(shapes.output, 2) * ceil(dim(shapes.output, 3) / 4)", "outWGroups": "ceil(dim(shapes.output, 3) / 4)", "outC": "dim(shapes.output, 1)", "outH": "dim(shapes.output, 2)", "outW": "dim(shapes.output, 3)", "inC": "dim(shapes.input, 1)", "inH": "dim(shapes.input, 2)", "inW": "dim(shapes.input, 3)" } }, "bindings": "io", "dispatch": { "threads": "dim(shapes.output, 0) * dim(shapes.output, 1) * dim(shapes.output, 2) * ceil(dim(shapes.output, 3) / 4)", "workgroupSize": "tunables.WORKGROUP_SIZE" } } ] } ]}12345678910111213141516171819{ "name": "ai.onnx.DepthToSpace", "id": "_ai_onnx_depthtospace_webgpu_ea6e538", "version": 1, "license": "Apache-2.0", "backend": { "type": "webgpu" }, "digest": { "algorithm": "sha256", "files": { "bench.json": "437M7+npzBe6ifdJlYIgSUZqHw1gO0A7/aRUKJ2NJVY=", "depth-to-space-nchw-coarsened4.wgsl.jinja": "onMG0dd/K41+1hEnl7TddZRLG3CBjjy40MOlZPnrkV0=", "manifest.json": "n4i4VOtp2TXrMC5FwnUM2I16OunwYl0aBPPsFYhDsgU=", "space-depth-permute.wgsl.jinja": "TNRb9rw4b8VDiWMXKSCAaZQUOI+jx4LngtZHiqG3Dg8=", "test.json": "MmJ58u1S776RqIS1psfK6ogGNMRWfjVOghdVgodij3c=" } }, "provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } }, "webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/ai.onnx.DepthToSpace" }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081{% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}{% if note == "dispatch-limit" %} // 2D-folded flat index: gid.y carries the high bits past the // maxComputeWorkgroupsPerDimension dispatch limit (outputs > 16.7M elements).{% elif note == "limit" %} // 2D-folded flat index: gid.y carries the high bits past the // maxComputeWorkgroupsPerDimension limit.{% elif note == "device-axis" %} // The flat dispatch is folded across x/y at the device's per-axis workgroup // limit; gid.y carries the high portion of the output index.{% elif note == "vec4-limit" %} // 2D-folded flat vec4 index: gid.y carries the high bits past the // maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills into y).{% elif note == "element-limit" %} // 2D-folded flat element index: gid.y carries the high bits past the // maxComputeWorkgroupsPerDimension limit.{% elif note == "dispatch" %} // 2D-folded flat index: gid.y carries the high bits past the // maxComputeWorkgroupsPerDimension dispatch limit.{% endif %}{% if bound == "" %} let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;{%- elif guardInline %} let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u; if ({{ name }} >= {{ bound }}) { return; }{%- else %} let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u; if ({{ name }} >= {{ bound }}) { return; }{%- endif %}{% endmacro %}
{% if usesF16 %}enable f16;{% endif %}{{ env.wgsl.resourceDeclarations }}
// Specializing all geometry lets division and modulo lower to constant// multiply-high/shift sequences. max(1) keeps zero-sized tensors compilable;// they dispatch no work.const COUNT: u32 = {{ source.count }}u;const OUT_W_UNITS: u32 = max(1u, {{ source.outWUnits }}u);const OUT_H: u32 = max(1u, {{ source.outH }}u);const OUT_C: u32 = max(1u, {{ source.outC }}u);const IN_C: u32 = max(1u, {{ source.inC }}u);const IN_H: u32 = {{ source.inH }}u;const IN_W: u32 = {{ source.inW }}u;const BLOCK_SIZE: u32 = {{ source.blocksize }}u;
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {{{ flat_index_2d("out_unit", "COUNT", note="") }}
let ow_unit = out_unit % OUT_W_UNITS; var remaining = out_unit / OUT_W_UNITS; let oh = remaining % OUT_H; remaining /= OUT_H; let oc = remaining % OUT_C; let n = remaining / OUT_C; let ow_base = ow_unit * {{ 4 if source.vectorized else 1 }}u;{% for lane in range(4 if source.vectorized else 1) %} let ow{{ lane }} = ow_base + {{ lane }}u; let bh{{ lane }} = oh % BLOCK_SIZE; let bw{{ lane }} = ow{{ lane }} % BLOCK_SIZE; let ih{{ lane }} = oh / BLOCK_SIZE; let iw{{ lane }} = ow{{ lane }} / BLOCK_SIZE;{% if source.mode == "CRD" %} let ic{{ lane }} = (oc * BLOCK_SIZE + bh{{ lane }}) * BLOCK_SIZE + bw{{ lane }};{% else %} let ic{{ lane }} = (bh{{ lane }} * BLOCK_SIZE + bw{{ lane }}) * OUT_C + oc;{% endif %} let value{{ lane }} = input[((n * IN_C + ic{{ lane }}) * IN_H + ih{{ lane }}) * IN_W + iw{{ lane }}];{% endfor %}
{% if source.vectorized %} output[out_unit] = {{ vectorScalar }}(value0, value1, value2, value3);{% else %} output[out_unit] = value0;{% endif %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592{ "op": "ai.onnx.DepthToSpace", "fixtureArrays": { "dcr_input_input": [0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33], "onnx_backend_dcr_1x8x2x3_input_input": [0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 18, 19, 20, 21, 22, 23, 27, 28, 29, 30, 31, 32, 36, 37, 38, 39, 40, 41, 45, 46, 47, 48, 49, 50, 54, 55, 56, 57, 58, 59, 63, 64, 65, 66, 67, 68], "ort_webgpu_default_mode_batch2_wide_input_input": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31] }, "cases": [ { "name": "blocksize3_dcr_odd_input_width_coarsened", "attrs": { "blocksize": 3, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 9, 24, 19], "data": { "kind": "linspace", "start": 0.0, "end": 4103.0 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 72, 57], "tolerance": 0 } } }, { "name": "dispatch_cliff_nchw_dcr", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 4, 2048, 2049], "data": { "kind": "linspace", "start": 0.0, "end": 1.0 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 4096, 4098], "tolerance": 0 } } }, { "name": "dcr", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 4, 2, 2], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/dcr_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 4, 4] } } }, { "name": "crd", "attrs": { "blocksize": 2, "mode": "CRD" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 4, 2, 2], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/dcr_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 4, 4] } } }, { "name": "dcr_block3_multichannel", "attrs": { "blocksize": 3, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 18, 1, 2], "data": { "kind": "fillFloat32", "sinStep": 0.13, "cosStep": 0.37 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 3, 6] } } }, { "name": "dcr_high_channel_vec4_1x256x4x4", "provenance": { "notes": "Compact high-channel DCR sibling for the 1x256x64x64 DepthToSpace benchmark; preserves the vec4/channel-heavy shape family without benchmark-scale spatial size." }, "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 256, 4, 4], "data": { "kind": "fillFloat32", "sinStep": 0.017, "cosStep": 0.029, "scale": 0.5 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 64, 8, 8], "tolerance": 0 } } }, { "name": "crd_high_channel_vec4_1x256x4x4", "provenance": { "notes": "Compact high-channel CRD sibling for the 1x256x64x64 DepthToSpace benchmark; preserves the mode and channel-heavy vec4 regime without benchmark-scale spatial size." }, "attrs": { "blocksize": 2, "mode": "CRD" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 256, 4, 4], "data": { "kind": "fillFloat32", "sinStep": 0.019, "cosStep": 0.031, "scale": 0.5 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 64, 8, 8], "tolerance": 0 } } }, { "name": "onnx_backend_dcr_1x8x2x3", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 2, 3], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_dcr_1x8x2x3_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 4, 6], "tolerance": 0 } } }, { "name": "onnx_backend_crd_1x8x2x3", "attrs": { "blocksize": 2, "mode": "CRD" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 2, 3], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_dcr_1x8x2x3_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 4, 6], "tolerance": 0 } } }, { "name": "ort_opset7_default_dcr_1x8x1x2", "attrs": { "blocksize": 2 }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_1" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 1, 2], "data": { "kind": "values", "values": [0.0, 0.2, 2.0, 2.2, 0.1, 0.3, 2.1, 2.3, 1.0, 1.2, 3.0, 3.2, 1.1, 1.3, 3.1, 3.3] } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 2, 4], "tolerance": 0 } } }, { "name": "ort_opset7_default_dcr_batch2_channels12", "attrs": { "blocksize": 2 }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_2" }, "inputs": { "input": { "dtype": "float32", "shape": [2, 12, 3, 2], "data": { "kind": "values", "values": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 106.0, 107.0, 108.0, 109.0, 110.0, 111.0, 112.0, 113.0, 114.0, 115.0, 116.0, 117.0, 118.0, 119.0, 120.0, 121.0, 122.0, 123.0, 124.0, 125.0, 126.0, 127.0, 128.0, 129.0, 130.0, 131.0, 132.0, 133.0, 134.0, 135.0, 136.0, 137.0, 138.0, 139.0, 140.0, 141.0, 142.0, 143.0] } } }, "outputs": { "output": { "dtype": "float32", "shape": [2, 3, 6, 4], "tolerance": 0 } } }, { "name": "f16_crd_batch2_multichannel", "attrs": { "blocksize": 2, "mode": "CRD" }, "inputs": { "input": { "dtype": "float16", "shape": [2, 8, 1, 1], "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0] } } }, "outputs": { "output": { "dtype": "float16", "shape": [2, 2, 2, 2], "tolerance": 0 } } }, { "name": "ort_webgpu_default_mode_single_pixel", "attrs": { "blocksize": 2 }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_WebGPU_DefaultMode1" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 1, 1], "data": { "kind": "values", "values": [0.0, 9.0, 18.0, 27.0, 36.0, 45.0, 54.0, 63.0] } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 2, 2], "tolerance": 0 } } }, { "name": "ort_uint8_default_mode_single_pixel", "attrs": { "blocksize": 2 }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_3<uint8_t>", "notes": "ORT typed coverage includes uint8 DepthToSpace; this compact DCR/default-mode case keeps logical uint8 coverage small." }, "inputs": { "input": { "dtype": "uint8", "shape": [1, 8, 1, 1], "data": { "kind": "values", "values": [0, 9, 18, 27, 36, 45, 54, 63] } } }, "outputs": { "output": { "dtype": "uint8", "shape": [1, 2, 2, 2], "tolerance": 0, "data": { "kind": "values", "values": [0, 18, 36, 54, 9, 27, 45, 63] } } } }, { "name": "ort_webgpu_default_mode_batch2_wide", "attrs": { "blocksize": 2 }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_WebGPU_DefaultMode2" }, "inputs": { "input": { "dtype": "float32", "shape": [2, 8, 1, 2], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_webgpu_default_mode_batch2_wide_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [2, 2, 2, 4], "tolerance": 0 } } }, { "name": "ort_webgpu_dcr_single_pixel", "attrs": { "blocksize": 2, "mode": "DCR" }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_WebGPU_DCR1" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 1, 1], "data": { "kind": "values", "values": [0.0, 9.0, 18.0, 27.0, 36.0, 45.0, 54.0, 63.0] } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 2, 2], "tolerance": 0 } } }, { "name": "ort_webgpu_dcr_batch2_wide", "attrs": { "blocksize": 2, "mode": "DCR" }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_WebGPU_DCR2" }, "inputs": { "input": { "dtype": "float32", "shape": [2, 8, 1, 2], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_webgpu_default_mode_batch2_wide_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [2, 2, 2, 4], "tolerance": 0 } } }, { "name": "ort_crd_batched_reversed_second_batch", "attrs": { "blocksize": 2, "mode": "CRD" }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_CRD_Batched" }, "inputs": { "input": { "dtype": "float32", "shape": [2, 4, 2, 3], "data": { "kind": "values", "values": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 32.0, 31.0, 30.0, 29.0, 28.0, 27.0, 23.0, 22.0, 21.0, 20.0, 19.0, 18.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0] } } }, "outputs": { "output": { "dtype": "float32", "shape": [2, 1, 4, 6], "tolerance": 0 } } }, { "name": "ort_webgpu_crd_single_pixel", "attrs": { "blocksize": 2, "mode": "CRD" }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_WebGPU_CRD1" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 1, 1], "data": { "kind": "values", "values": [0.0, 9.0, 18.0, 27.0, 36.0, 45.0, 54.0, 63.0] } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 2, 2], "tolerance": 0 } } }, { "name": "ort_webgpu_crd_batch2_wide", "attrs": { "blocksize": 2, "mode": "CRD" }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_WebGPU_CRD2" }, "inputs": { "input": { "dtype": "float32", "shape": [2, 8, 1, 2], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_webgpu_default_mode_batch2_wide_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [2, 2, 2, 4], "tolerance": 0 } } }, { "name": "onnx_backend_depthtospace_crd_mode_example", "attrs": { "blocksize": 2, "mode": "CRD" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 2, 3], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_dcr_1x8x2x3_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 4, 6] } }, "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_depthtospace_crd_mode_example" } }, { "name": "onnx_backend_depthtospace_example", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 8, 2, 3], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_dcr_1x8x2x3_input_input" } } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 4, 6] } }, "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_depthtospace_example" } }, { "name": "ort_uint8_dcr_typed", "attrs": { "blocksize": 2, "mode": "DCR" }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_4", "notes": "Typed ORT coverage includes uint8; this framework stores logical uint8 values in 32-bit slots." }, "inputs": { "input": { "dtype": "uint8", "shape": [1, 8, 1, 1], "data": { "kind": "values", "values": [0, 9, 18, 27, 36, 45, 54, 63] } } }, "outputs": { "output": { "dtype": "uint8", "shape": [1, 2, 2, 2], "data": { "kind": "values", "values": [0, 18, 36, 54, 9, 27, 45, 63] }, "tolerance": 0 } } }, { "name": "ort_uint8_crd_typed", "attrs": { "blocksize": 2, "mode": "CRD" }, "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_5", "notes": "Typed ORT coverage includes uint8; this framework stores logical uint8 values in 32-bit slots." }, "inputs": { "input": { "dtype": "uint8", "shape": [1, 8, 1, 1], "data": { "kind": "values", "values": [0, 9, 18, 27, 36, 45, 54, 63] } } }, "outputs": { "output": { "dtype": "uint8", "shape": [1, 2, 2, 2], "data": { "kind": "values", "values": [0, 9, 18, 27, 36, 45, 54, 63] }, "tolerance": 0 } } }, { "name": "empty_zero_dim", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [0, 4, 2, 2], "data": { "kind": "values", "values": [] } } }, "outputs": { "output": { "dtype": "float32", "shape": [0, 1, 4, 4], "tolerance": 0 } } }, { "name": "empty_zero_dim_f16", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float16", "shape": [0, 4, 2, 2], "data": { "kind": "values", "values": [] } } }, "outputs": { "output": { "dtype": "float16", "shape": [0, 1, 4, 4], "tolerance": 0 } } }, { "name": "crd_block3_2x2", "attrs": { "blocksize": 3, "mode": "CRD" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 18, 2, 2], "data": { "kind": "values", "values": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0] } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 2, 6, 6], "tolerance": 0 } } }, { "name": "f16_dcr_vec4_path", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "float16", "shape": [1, 8, 1, 2], "data": { "kind": "values", "values": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0] } } }, "outputs": { "output": { "dtype": "float16", "shape": [1, 2, 2, 4], "tolerance": 0.001 } } }, { "name": "uint8_dcr_vec4_path", "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "uint8", "shape": [1, 8, 1, 2], "data": { "kind": "values", "values": [0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240] } } }, "outputs": { "output": { "dtype": "uint8", "shape": [1, 2, 2, 4], "tolerance": 0 } } }, { "name": "blocksize_1_identity_dcr", "attrs": { "blocksize": 1, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 4, 3, 5], "data": { "kind": "fillFloat32", "sinStep": 0.25, "cosStep": 0.41, "scale": 2.0 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 4, 3, 5], "tolerance": 0 } } }, { "name": "blocksize_4_dcr_nontrivial_reorder", "attrs": { "blocksize": 4, "mode": "DCR" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 16, 2, 4], "data": { "kind": "linspace", "start": 0.0, "end": 1.0 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 8, 16], "tolerance": 0 } } }, { "name": "ort_standard_int32_dcr_extremes", "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_int_opset13", "notes": "ONNX DepthToSpace-13 permits int32; signed extrema prove the widened i32 route is a bit-exact permutation." }, "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "int32", "shape": [1, 4, 1, 2], "data": { "kind": "values", "values": [-2147483648, 2147483647, -16777217, 16777217, -1, 0, 42, -42] } } }, "outputs": { "output": { "dtype": "int32", "shape": [1, 1, 2, 4], "tolerance": 0 } } }, { "name": "ort_standard_int16_dcr_extremes", "provenance": { "source": "onnx/docs/Operators.md#DepthToSpace", "notes": "ONNX DepthToSpace-13 permits int16; both signed extrema guard the runtime's widened i32 storage route." }, "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "int16", "shape": [1, 4, 1, 2], "data": { "kind": "values", "values": [-32768, 32767, -12345, 12345, -1, 0, 42, -42] } } }, "outputs": { "output": { "dtype": "int16", "shape": [1, 1, 2, 4], "tolerance": 0 } } }, { "name": "ort_standard_int8_dcr_extremes", "provenance": { "source": "onnxruntime/test/providers/cpu/tensor/space_depth_ops_test.cc", "test": "TensorOpTest.DepthToSpaceTest_int_opset13", "notes": "Uses both int8 extrema so the widened i32 storage route cannot hide narrowing or sign loss." }, "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "int8", "shape": [1, 4, 1, 2], "data": { "kind": "values", "values": [-128, 127, -64, 63, -1, 0, 42, -42] } } }, "outputs": { "output": { "dtype": "int8", "shape": [1, 1, 2, 4], "tolerance": 0 } } }, { "name": "ort_standard_uint32_dcr_extremes", "provenance": { "source": "onnx/docs/Operators.md#DepthToSpace", "notes": "ONNX DepthToSpace-13 permits uint32; values across the signed boundary and UINT32_MAX guard exact u32 payload movement." }, "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "uint32", "shape": [1, 4, 1, 2], "data": { "kind": "values", "values": [0, 4294967295, 16777217, 2147483648, 1, 42, 4000000000, 255] } } }, "outputs": { "output": { "dtype": "uint32", "shape": [1, 1, 2, 4], "tolerance": 0 } } }, { "name": "ort_standard_bool_dcr_pattern", "provenance": { "source": "onnx/docs/Operators.md#DepthToSpace", "notes": "ONNX DepthToSpace-13 permits bool; an asymmetric pattern checks that widened u32 boolean payloads are reordered without conversion." }, "attrs": { "blocksize": 2, "mode": "DCR" }, "inputs": { "input": { "dtype": "bool", "shape": [1, 4, 1, 2], "data": { "kind": "values", "values": [0, 1, 1, 0, 1, 1, 0, 0] } } }, "outputs": { "output": { "dtype": "bool", "shape": [1, 1, 2, 4], "tolerance": 0 } } }, { "name": "blocksize3_dcr_odd_input_width_coarsened_f16", "provenance": { "notes": "A float16 coarsened odd-width shuffle uses an output width not divisible by four and at least 4096 output elements. Data is scaled into [0, 1] so all copied values remain accurately representable." }, "attrs": { "blocksize": 3, "mode": "DCR" }, "inputs": { "input": { "dtype": "float16", "shape": [1, 9, 24, 19], "data": { "kind": "linspace", "start": 0.0, "end": 1.0 } } }, "outputs": { "output": { "dtype": "float16", "shape": [1, 1, 72, 57], "tolerance": 0 } } }, { "name": "blocksize3_crd_odd_input_width_coarsened", "provenance": { "notes": "CRD mode on the coarsened path checks its distinct channel-unpacking order. The output width is not divisible by four and the output has at least 4096 elements." }, "attrs": { "blocksize": 3, "mode": "CRD" }, "inputs": { "input": { "dtype": "float32", "shape": [1, 9, 24, 19], "data": { "kind": "linspace", "start": 0.0, "end": 4103.0 } } }, "outputs": { "output": { "dtype": "float32", "shape": [1, 1, 72, 57], "tolerance": 0 } } } ]}README.md+68
build/webgpu/bench.jsonAdded+69
build/webgpu/depth-to-space-nchw-coarsened4.wgsl.jinjaAdded+52
build/webgpu/manifest.jsonAdded+145
build/webgpu/metadata.jsonAdded+19
build/webgpu/space-depth-permute.wgsl.jinjaAdded+81
build/webgpu/test.jsonAdded+592