Xenova HF Staff commited on
Commit
0dcee9d
·
verified ·
1 Parent(s): beb58fa

sync 2e7068faf55e

Browse files
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.Shape
10
+
11
+ `ai.onnx` · standard ONNX operator · ONNX opset ≥ 15
12
+
13
+ ## Description
14
+
15
+ Returns a 1-D tensor containing the shape of the input tensor. Optional `start` and `end` attributes select a slice of the shape axes; negative values count from the back, and axes are clamped to `[0, rank]`.
16
+
17
+ See the [ONNX `Shape` spec](https://onnx.ai/onnx/operators/onnx__Shape.html) for the reference semantics.
18
+
19
+ ## Inputs
20
+
21
+ | Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
22
+ | --- | --- | --- | --- | --- | --- | --- |
23
+ | `data` | `data` | `T` | — | — | The input tensor whose shape is computed. | required |
24
+
25
+ ## Outputs
26
+
27
+ | Name | Bind key | Logical dtype | WebGPU storage | Rank | Shape | Description | Presence |
28
+ | --- | --- | --- | --- | --- | --- | --- | --- |
29
+ | `shape` | `shape` | `S` | `uint32` | `1` | derived; see description | Logical int64 1-D tensor of dimension sizes for the selected axes of the input; WebGPU emits bounded uint32 values. | required |
30
+
31
+ ## Attributes
32
+
33
+ Attributes and default values (overridable per request):
34
+
35
+ | Attribute | Default | Description |
36
+ | --- | --- | --- |
37
+ | `start` | `0` | First axis (inclusive) of the shape slice; negative values count from the back, default is 0. |
38
+ | `end` | — | Last axis (exclusive) of the shape slice; negative values count from the back; if omitted, all axes through the last are included. |
39
+
40
+ ## Type constraints
41
+
42
+ | Variable | Allowed dtypes |
43
+ | --- | --- |
44
+ | `T` | `float32`, `float16`, `int32`, `int16`, `uint32`, `int8`, `uint8`, `bool` |
45
+ | `S` | `int64` |
46
+
47
+ ## Files
48
+
49
+ - [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, provenance)
50
+ - [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
51
+ - [`test.json`](build/webgpu/test.json) — correctness cases
52
+ - [`bench.json`](build/webgpu/bench.json) — benchmark + tuning cases
53
+ - [`shape.wgsl.jinja`](build/webgpu/shape.wgsl.jinja)
54
+
55
+ ## Use with `@huggingface/kernels`
56
+
57
+ The loader derives every required output's shape and logical dtype from the manifest contract and this call.
58
+ It then allocates the result tensors automatically.
59
+
60
+ The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
61
+
62
+ Replace each `*Data` placeholder with a typed array containing the corresponding input data.
63
+
64
+ ```js
65
+ import { getKernel } from "@huggingface/kernels";
66
+
67
+ const kernel = await getKernel("webgpu-kernels/ai.onnx.Shape", { version: 1 });
68
+ const { shape } = await kernel({ data: { data: dataData, shape: [1, 2, 2] } });
69
+ ```
build/webgpu/bench.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "op": "ai.onnx.Shape",
3
+ "cases": [
4
+ {
5
+ "name": "rank4",
6
+ "inputs": { "data": { "dtype": "float32", "shape": [1, 16, 128, 128] } },
7
+ "outputs": { "shape": { "dtype": "uint32", "shape": [4] } },
8
+ "bench": { "metrics": [{ "type": "bandwidth", "name": "write-BW", "value": "4 * numel(shapes.shape)" }] },
9
+ "preset": "smoke"
10
+ },
11
+ {
12
+ "name": "rank7_full_shape_gpu_gap",
13
+ "inputs": { "data": { "dtype": "float32", "shape": [1, 2, 1, 3, 1, 4, 1] } },
14
+ "outputs": { "shape": { "dtype": "uint32", "shape": [7] } },
15
+ "bench": { "metrics": [{ "type": "bandwidth", "name": "write-BW", "value": "4 * numel(shapes.shape)" }] }
16
+ }
17
+ ]
18
+ }
build/webgpu/manifest.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "ai.onnx",
3
+ "name": "Shape",
4
+ "sinceVersion": 15,
5
+ "description": "Returns a 1-D tensor containing the shape of the input tensor. Optional `start` and `end` attributes select a slice of the shape axes; negative values count from the back, and axes are clamped to `[0, rank]`.",
6
+ "inputs": [{ "role": "data", "dtype": "T", "description": "The input tensor whose shape is computed." }],
7
+ "outputs": [
8
+ {
9
+ "role": "shape",
10
+ "dtype": "S",
11
+ "rank": 1,
12
+ "description": "Logical int64 1-D tensor of dimension sizes for the selected axes of the input; WebGPU emits bounded uint32 values.",
13
+ "shape": ["max(0, endAxis - startAxis)"]
14
+ }
15
+ ],
16
+ "attributes": { "start": 0 },
17
+ "attributeDescriptions": {
18
+ "start": "First axis (inclusive) of the shape slice; negative values count from the back, default is 0.",
19
+ "end": "Last axis (exclusive) of the shape slice; negative values count from the back; if omitted, all axes through the last are included."
20
+ },
21
+ "typeConstraints": {
22
+ "T": ["float32", "float16", "int32", "int16", "uint32", "int8", "uint8", "bool"],
23
+ "S": ["int64"]
24
+ },
25
+ "args": {
26
+ "data": { "kind": "tensor", "semantic": "data", "role": "input" },
27
+ "shape": { "kind": "tensor", "semantic": "shape", "role": "output", "dtype": "uint32" }
28
+ },
29
+ "derive": {
30
+ "startAxis": "max(0, min(ranks.data, attrs.start + (ranks.data if attrs.start < 0 else 0)))",
31
+ "endParam": "attrs.end if has(attrs, \"end\") else ranks.data",
32
+ "endAxis": "min(ranks.data, endParam + (ranks.data if endParam < 0 else 0))"
33
+ },
34
+ "variants": [
35
+ {
36
+ "id": "full_shape",
37
+ "when": ["ranks.shape == 1", "dim(shapes.shape, 0) == max(0, endAxis - startAxis)"],
38
+ "passes": [
39
+ {
40
+ "id": "main",
41
+ "name": "Shape",
42
+ "source": {
43
+ "shader": "shape.wgsl.jinja",
44
+ "inputs": {
45
+ "inputShape": "shapes.data",
46
+ "rank": "ranks.data",
47
+ "start": "startAxis",
48
+ "outputRank": "dim(shapes.shape, 0)"
49
+ }
50
+ },
51
+ "bindings": [
52
+ {
53
+ "name": "shape",
54
+ "arg": "shape",
55
+ "semantic": "shape",
56
+ "buffer": { "type": "storage" },
57
+ "elementType": "u32"
58
+ }
59
+ ],
60
+ "dispatch": { "x": 1 }
61
+ }
62
+ ]
63
+ }
64
+ ]
65
+ }
build/webgpu/metadata.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ai.onnx.Shape",
3
+ "id": "_ai_onnx_shape_webgpu_353de3d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "backend": { "type": "webgpu" },
7
+ "digest": {
8
+ "algorithm": "sha256",
9
+ "files": {
10
+ "bench.json": "kiw8iMiBPBGaaz6TKqd9RaaOn38QOi/xilG0TXGnttQ=",
11
+ "manifest.json": "Y8kEIxBXPtwm8XOQcctfW9bFg8RGzmi1r7HwvpwrEPY=",
12
+ "shape.wgsl.jinja": "J1oIMamgxFx04z+NWiHv6zFj8vclOHR99dd4R/GsPzY=",
13
+ "test.json": "U5HvTdgN4iqjYIRxu51OW8NZCuqqj/oRlYrEEruggIM="
14
+ }
15
+ },
16
+ "provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } },
17
+ "webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/ai.onnx.Shape" }
18
+ }
build/webgpu/shape.wgsl.jinja ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{ env.wgsl.resourceDeclarations }}
2
+
3
+ @compute @workgroup_size(1)
4
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
5
+ if (gid.x != 0u) {
6
+ return;
7
+ }
8
+ {% for dim in source.inputShape %}
9
+ {% if loop.index0 >= source.start and loop.index0 < source.start + source.outputRank %}
10
+ shape[{{ loop.index0 - source.start }}u] = {{ dim }}u;
11
+ {% endif %}
12
+ {% endfor %}
13
+ }
build/webgpu/test.json ADDED
@@ -0,0 +1,410 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "op": "ai.onnx.Shape",
3
+ "cases": [
4
+ {
5
+ "name": "rank3_f32",
6
+ "inputs": { "data": { "dtype": "float32", "shape": [2, 3, 4] } },
7
+ "outputs": { "shape": { "dtype": "uint32", "shape": [3] } }
8
+ },
9
+ {
10
+ "name": "rank4_u32",
11
+ "inputs": { "data": { "dtype": "uint32", "shape": [1, 2, 3, 4] } },
12
+ "outputs": { "shape": { "dtype": "uint32", "shape": [4] } }
13
+ },
14
+ {
15
+ "name": "rank0_scalar_input_empty_shape_vector",
16
+ "inputs": { "data": { "dtype": "float32", "shape": [] } },
17
+ "outputs": { "shape": { "dtype": "uint32", "shape": [0], "tolerance": 0 } }
18
+ },
19
+ {
20
+ "name": "ort_interior_zero_dim_reports_zero",
21
+ "provenance": {
22
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
23
+ "test": "ShapeOpTest.ShapeOpset15_Default",
24
+ "notes": "Additional node-level zero-dimension edge: Shape must report an interior zero dimension exactly."
25
+ },
26
+ "inputs": { "data": { "dtype": "float32", "shape": [2, 0, 3], "data": { "kind": "values", "values": [] } } },
27
+ "outputs": {
28
+ "shape": { "dtype": "uint32", "shape": [3], "tolerance": 0, "data": { "kind": "values", "values": [2, 0, 3] } }
29
+ }
30
+ },
31
+ {
32
+ "name": "start_end_middle_dims",
33
+ "attrs": { "start": 1, "end": 3 },
34
+ "inputs": { "data": { "dtype": "float32", "shape": [2, 3, 4, 5] } },
35
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
36
+ },
37
+ {
38
+ "name": "negative_start_negative_end",
39
+ "attrs": { "start": -3, "end": -1 },
40
+ "inputs": { "data": { "dtype": "float32", "shape": [2, 3, 4, 5] } },
41
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
42
+ },
43
+ {
44
+ "name": "ort_start_equals_end_empty_slice",
45
+ "provenance": {
46
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
47
+ "test": "ShapeOpTest.ShapeOpset15_StartAndEndProducingEmptySlice"
48
+ },
49
+ "attrs": { "start": 2, "end": 2 },
50
+ "inputs": {
51
+ "data": { "dtype": "int32", "shape": [1, 2, 2], "data": { "kind": "values", "values": [1, 2, 3, 4] } }
52
+ },
53
+ "outputs": { "shape": { "dtype": "uint32", "shape": [0], "tolerance": 0 } }
54
+ },
55
+ {
56
+ "name": "ort_int8_shape_3x4",
57
+ "provenance": {
58
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
59
+ "test": "ShapeOpTest.ShapeTestInt8"
60
+ },
61
+ "inputs": {
62
+ "data": {
63
+ "dtype": "int8",
64
+ "shape": [3, 4],
65
+ "data": { "kind": "values", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }
66
+ }
67
+ },
68
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
69
+ },
70
+ {
71
+ "name": "ort_int16_shape_3x4",
72
+ "provenance": {
73
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
74
+ "test": "ShapeOpTest.ShapeTestInt16"
75
+ },
76
+ "inputs": {
77
+ "data": {
78
+ "dtype": "int16",
79
+ "shape": [3, 4],
80
+ "data": { "kind": "values", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }
81
+ }
82
+ },
83
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
84
+ },
85
+ {
86
+ "name": "ort_uint8_shape_12x1",
87
+ "provenance": {
88
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
89
+ "test": "ShapeOpTest.ShapeTestUint8"
90
+ },
91
+ "inputs": {
92
+ "data": {
93
+ "dtype": "uint8",
94
+ "shape": [12, 1],
95
+ "data": { "kind": "values", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }
96
+ }
97
+ },
98
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
99
+ },
100
+ {
101
+ "name": "ort_int32_shape_4x3",
102
+ "provenance": {
103
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
104
+ "test": "ShapeOpTest.ShapeTestInt32"
105
+ },
106
+ "inputs": {
107
+ "data": {
108
+ "dtype": "int32",
109
+ "shape": [4, 3],
110
+ "data": { "kind": "values", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }
111
+ }
112
+ },
113
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
114
+ },
115
+ {
116
+ "name": "ort_int32_default_opset15",
117
+ "provenance": {
118
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
119
+ "test": "ShapeOpTest.ShapeOpset15_Default"
120
+ },
121
+ "inputs": {
122
+ "data": { "dtype": "int32", "shape": [1, 2, 2], "data": { "kind": "values", "values": [1, 2, 3, 4] } }
123
+ },
124
+ "outputs": { "shape": { "dtype": "uint32", "shape": [3], "tolerance": 0 } }
125
+ },
126
+ {
127
+ "name": "ort_start_only_int32",
128
+ "provenance": {
129
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
130
+ "test": "ShapeOpTest.ShapeOpset15_StartOnly"
131
+ },
132
+ "attrs": { "start": 1 },
133
+ "inputs": {
134
+ "data": { "dtype": "int32", "shape": [1, 2, 2], "data": { "kind": "values", "values": [1, 2, 3, 4] } }
135
+ },
136
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
137
+ },
138
+ {
139
+ "name": "ort_end_only_int32",
140
+ "provenance": {
141
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
142
+ "test": "ShapeOpTest.ShapeOpset15_EndOnly"
143
+ },
144
+ "attrs": { "end": 2 },
145
+ "inputs": {
146
+ "data": { "dtype": "int32", "shape": [1, 2, 2], "data": { "kind": "values", "values": [1, 2, 3, 4] } }
147
+ },
148
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
149
+ },
150
+ {
151
+ "name": "ort_start_and_end_int32",
152
+ "provenance": {
153
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
154
+ "test": "ShapeOpTest.ShapeOpset15_StartAndEnd"
155
+ },
156
+ "attrs": { "start": 1, "end": 2 },
157
+ "inputs": {
158
+ "data": { "dtype": "int32", "shape": [1, 2, 2], "data": { "kind": "values", "values": [1, 2, 3, 4] } }
159
+ },
160
+ "outputs": { "shape": { "dtype": "uint32", "shape": [1], "tolerance": 0 } }
161
+ },
162
+ {
163
+ "name": "ort_negative_start_and_end_int32",
164
+ "provenance": {
165
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
166
+ "test": "ShapeOpTest.ShapeOpset15_StartAndEndNegative"
167
+ },
168
+ "attrs": { "start": -2, "end": -1 },
169
+ "inputs": {
170
+ "data": { "dtype": "int32", "shape": [1, 2, 2], "data": { "kind": "values", "values": [1, 2, 3, 4] } }
171
+ },
172
+ "outputs": { "shape": { "dtype": "uint32", "shape": [1], "tolerance": 0 } }
173
+ },
174
+ {
175
+ "name": "ort_float_shape_2x6",
176
+ "provenance": {
177
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
178
+ "test": "ShapeOpTest.ShapeTestFloat"
179
+ },
180
+ "inputs": {
181
+ "data": {
182
+ "dtype": "float32",
183
+ "shape": [2, 6],
184
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0] }
185
+ }
186
+ },
187
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
188
+ },
189
+ {
190
+ "name": "ort_bool_exact_shape_2x3",
191
+ "provenance": {
192
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
193
+ "test": "ShapeOpTest.ShapeTestBool"
194
+ },
195
+ "inputs": {
196
+ "data": { "dtype": "bool", "shape": [2, 3], "data": { "kind": "values", "values": [1, 1, 0, 0, 1, 0] } }
197
+ },
198
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
199
+ },
200
+ {
201
+ "name": "ort_uint32_shape_12x1",
202
+ "provenance": {
203
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
204
+ "test": "ShapeOpTest.ShapeTestUint32"
205
+ },
206
+ "inputs": {
207
+ "data": {
208
+ "dtype": "uint32",
209
+ "shape": [12, 1],
210
+ "data": { "kind": "values", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }
211
+ }
212
+ },
213
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
214
+ },
215
+ {
216
+ "name": "ort_bool_shape_logical_uint32_2x3",
217
+ "provenance": {
218
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
219
+ "test": "ShapeOpTest.ShapeTestBool",
220
+ "notes": "Logical bool fixture represented with uint32 storage slots."
221
+ },
222
+ "inputs": {
223
+ "data": { "dtype": "uint32", "shape": [2, 3], "data": { "kind": "values", "values": [1, 1, 0, 0, 1, 0] } }
224
+ },
225
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
226
+ },
227
+ {
228
+ "name": "ort_bool_shape_exact_2x3",
229
+ "provenance": {
230
+ "source": "onnxruntime/test/providers/cpu/tensor/shape_op_test.cc",
231
+ "test": "ShapeOpTest.ShapeTestBool"
232
+ },
233
+ "inputs": {
234
+ "data": { "dtype": "bool", "shape": [2, 3], "data": { "kind": "values", "values": [1, 1, 0, 0, 1, 0] } }
235
+ },
236
+ "outputs": {
237
+ "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0, "data": { "kind": "values", "values": [2, 3] } }
238
+ }
239
+ },
240
+ {
241
+ "name": "onnx_backend_shape",
242
+ "provenance": {
243
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape",
244
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
245
+ },
246
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
247
+ "outputs": { "shape": { "dtype": "uint32", "shape": [3], "tolerance": 0 } }
248
+ },
249
+ {
250
+ "name": "onnx_backend_shape_clip_end",
251
+ "provenance": {
252
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_clip_end",
253
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
254
+ },
255
+ "attrs": { "end": 10 },
256
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
257
+ "outputs": { "shape": { "dtype": "uint32", "shape": [3], "tolerance": 0 } }
258
+ },
259
+ {
260
+ "name": "onnx_backend_shape_clip_start",
261
+ "provenance": {
262
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_clip_start",
263
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
264
+ },
265
+ "attrs": { "start": -10 },
266
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
267
+ "outputs": { "shape": { "dtype": "uint32", "shape": [3], "tolerance": 0 } }
268
+ },
269
+ {
270
+ "name": "onnx_backend_shape_end_1",
271
+ "provenance": {
272
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_end_1",
273
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
274
+ },
275
+ "attrs": { "end": 1 },
276
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
277
+ "outputs": { "shape": { "dtype": "uint32", "shape": [1], "tolerance": 0 } }
278
+ },
279
+ {
280
+ "name": "onnx_backend_shape_end_negative_1",
281
+ "provenance": {
282
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_end_negative_1",
283
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
284
+ },
285
+ "attrs": { "end": -1 },
286
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
287
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
288
+ },
289
+ {
290
+ "name": "onnx_backend_shape_example",
291
+ "provenance": {
292
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_example",
293
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
294
+ },
295
+ "inputs": { "data": { "dtype": "float32", "shape": [2, 3] } },
296
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
297
+ },
298
+ {
299
+ "name": "onnx_backend_shape_start_1",
300
+ "provenance": {
301
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_start_1",
302
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
303
+ },
304
+ "attrs": { "start": 1 },
305
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
306
+ "outputs": { "shape": { "dtype": "uint32", "shape": [2], "tolerance": 0 } }
307
+ },
308
+ {
309
+ "name": "onnx_backend_shape_start_1_end_2",
310
+ "provenance": {
311
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_start_1_end_2",
312
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
313
+ },
314
+ "attrs": { "end": 2, "start": 1 },
315
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
316
+ "outputs": { "shape": { "dtype": "uint32", "shape": [1], "tolerance": 0 } }
317
+ },
318
+ {
319
+ "name": "onnx_backend_shape_start_1_end_negative_1",
320
+ "provenance": {
321
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_start_1_end_negative_1",
322
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
323
+ },
324
+ "attrs": { "end": -1, "start": 1 },
325
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
326
+ "outputs": { "shape": { "dtype": "uint32", "shape": [1], "tolerance": 0 } }
327
+ },
328
+ {
329
+ "name": "onnx_backend_shape_start_greater_than_end",
330
+ "provenance": {
331
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_start_greater_than_end",
332
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
333
+ },
334
+ "attrs": { "end": 1, "start": 2 },
335
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
336
+ "outputs": { "shape": { "dtype": "uint32", "shape": [0], "tolerance": 0 } }
337
+ },
338
+ {
339
+ "name": "onnx_backend_shape_start_negative_1",
340
+ "provenance": {
341
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_shape_start_negative_1",
342
+ "notes": "ONNX shape/size outputs are int64; this framework uses uint32 shape/index storage."
343
+ },
344
+ "attrs": { "start": -1 },
345
+ "inputs": { "data": { "dtype": "float32", "shape": [3, 4, 5] } },
346
+ "outputs": { "shape": { "dtype": "uint32", "shape": [1], "tolerance": 0 } }
347
+ },
348
+ {
349
+ "name": "ort_caseB_empty",
350
+ "inputs": { "data": { "dtype": "float32", "shape": [0, 3, 4], "data": { "kind": "values", "values": [] } } },
351
+ "outputs": {
352
+ "shape": { "dtype": "uint32", "shape": [3], "data": { "kind": "values", "values": [0, 3, 4] }, "tolerance": 0 }
353
+ }
354
+ },
355
+ {
356
+ "name": "rank3_f16",
357
+ "inputs": { "data": { "dtype": "float16", "shape": [2, 3, 4] } },
358
+ "outputs": { "shape": { "dtype": "uint32", "shape": [3] } }
359
+ },
360
+ {
361
+ "name": "rank6_negative_start_clip",
362
+ "attrs": { "start": -7 },
363
+ "inputs": { "data": { "dtype": "float32", "shape": [2, 3, 4, 5, 6, 7] } },
364
+ "outputs": {
365
+ "shape": {
366
+ "dtype": "uint32",
367
+ "shape": [6],
368
+ "tolerance": 0,
369
+ "data": { "kind": "values", "values": [2, 3, 4, 5, 6, 7] }
370
+ }
371
+ }
372
+ },
373
+ {
374
+ "name": "rank6_start_end_middle_negative",
375
+ "attrs": { "start": -4, "end": -1 },
376
+ "inputs": { "data": { "dtype": "uint32", "shape": [2, 3, 4, 5, 6, 7] } },
377
+ "outputs": {
378
+ "shape": { "dtype": "uint32", "shape": [3], "tolerance": 0, "data": { "kind": "values", "values": [4, 5, 6] } }
379
+ }
380
+ },
381
+ {
382
+ "name": "rank7_full_shape",
383
+ "provenance": {
384
+ "source": "onnx spec: Shape returns the input tensor dimensions",
385
+ "notes": "Small rank-7 sentinel. ORT CPU returns [1,2,1,3,1,4,1]; full_shape is rank-agnostic, and rank8_full_shape covers the band above it."
386
+ },
387
+ "inputs": { "data": { "dtype": "float32", "shape": [1, 2, 1, 3, 1, 4, 1] } },
388
+ "outputs": {
389
+ "shape": {
390
+ "dtype": "uint32",
391
+ "shape": [7],
392
+ "tolerance": 0,
393
+ "data": { "kind": "values", "values": [1, 2, 1, 3, 1, 4, 1] }
394
+ }
395
+ }
396
+ },
397
+ {
398
+ "name": "rank8_full_shape",
399
+ "inputs": { "data": { "dtype": "float32", "shape": [1, 2, 1, 3, 1, 4, 1, 2] } },
400
+ "outputs": {
401
+ "shape": {
402
+ "dtype": "uint32",
403
+ "shape": [8],
404
+ "tolerance": 0,
405
+ "data": { "kind": "values", "values": [1, 2, 1, 3, 1, 4, 1, 2] }
406
+ }
407
+ }
408
+ }
409
+ ]
410
+ }