Xenova HF Staff commited on
Commit
ae996ee
·
verified ·
1 Parent(s): 49b3ea5

sync 2e7068faf55e

Browse files
README.md CHANGED
@@ -1,3 +1,63 @@
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.Less
10
+
11
+ `ai.onnx` · standard ONNX operator · ONNX opset ≥ 13
12
+
13
+ ## Description
14
+
15
+ Performs an elementwise `less-than` comparison between tensors `A` and `B` with NumPy-style multidirectional broadcasting, producing a boolean result tensor `C`. Each output element is `true` where the corresponding element of `A` is strictly less than that of `B`.
16
+
17
+ See the [ONNX `Less` spec](https://onnx.ai/onnx/operators/onnx__Less.html) for the reference semantics.
18
+
19
+ ## Inputs
20
+
21
+ | Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
22
+ | --- | --- | --- | --- | --- | --- | --- |
23
+ | `A` | `a` | `T` | — | — | First input operand for the less-than comparison. | required |
24
+ | `B` | `b` | `T` | — | — | Second input operand for the less-than comparison. | required |
25
+
26
+ ## Outputs
27
+
28
+ | Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
29
+ | --- | --- | --- | --- | --- | --- | --- |
30
+ | `C` | `c` | `B` | derived | broadcast result of `A` and `B` | Boolean result tensor; true where A < B. | required |
31
+
32
+ ## Type constraints
33
+
34
+ | Variable | Allowed dtypes |
35
+ | --- | --- |
36
+ | `T` | `float32`, `float16`, `int32`, `int16`, `uint32`, `int8`, `uint8` |
37
+ | `B` | `bool` |
38
+
39
+ ## Files
40
+
41
+ - [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, provenance)
42
+ - [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
43
+ - [`test.json`](build/webgpu/test.json) — correctness cases
44
+ - [`bench.json`](build/webgpu/bench.json) — benchmark + tuning cases
45
+ - [`compare-broadcast-vec4.wgsl.jinja`](build/webgpu/compare-broadcast-vec4.wgsl.jinja)
46
+ - [`compare-broadcast.wgsl.jinja`](build/webgpu/compare-broadcast.wgsl.jinja)
47
+ - [`compare-vec4.wgsl.jinja`](build/webgpu/compare-vec4.wgsl.jinja)
48
+
49
+ ## Use with `@huggingface/kernels`
50
+
51
+ The loader derives every required output's shape and logical dtype from the manifest contract and this call.
52
+ It then allocates the result tensors automatically.
53
+
54
+ The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
55
+
56
+ Replace each `*Data` placeholder with a typed array containing the corresponding input data.
57
+
58
+ ```js
59
+ import { getKernel } from "@huggingface/kernels";
60
+
61
+ const kernel = await getKernel("webgpu-kernels/ai.onnx.Less", { version: 1 });
62
+ const { c } = await kernel({ a: { data: aData, shape: [] }, b: { data: bData, shape: [] } });
63
+ ```
build/webgpu/bench.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "op": "ai.onnx.Less",
3
+ "tunableSpace": { "WORKGROUP_SIZE": [64, 128, 256] },
4
+ "cases": [
5
+ {
6
+ "name": "1m_f32",
7
+ "preset": "smoke",
8
+ "inputs": { "a": { "dtype": "float32", "shape": [1048576] }, "b": { "dtype": "float32", "shape": [1048576] } },
9
+ "outputs": { "c": { "dtype": "bool", "shape": [1048576] } },
10
+ "bench": {
11
+ "metrics": [{ "type": "bandwidth", "value": "(numel(shapes.a) + numel(shapes.b) + numel(shapes.c)) * 4" }]
12
+ }
13
+ },
14
+ {
15
+ "name": "1m_f32_broadcast_scalar_odd_last_dim",
16
+ "preset": "edge",
17
+ "inputs": {
18
+ "a": { "dtype": "float32", "shape": [1024, 1025], "dist": "normal", "seed": 7, "scale": 2 },
19
+ "b": { "dtype": "float32", "shape": [1025], "dist": "normal", "seed": 8, "scale": 2 }
20
+ },
21
+ "outputs": { "c": { "dtype": "bool", "shape": [1024, 1025], "dist": "empty" } },
22
+ "bench": {
23
+ "metrics": [
24
+ { "type": "bandwidth", "value": "(numel(shapes.a) + numel(shapes.b) + numel(shapes.c)) * 4", "name": "GB/s" }
25
+ ]
26
+ }
27
+ }
28
+ ]
29
+ }
build/webgpu/compare-broadcast-vec4.wgsl.jinja ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro offset_fn(fn_name, opShape, opRank, op_same, op_numel, outShape, outRank, out_numel) %}
2
+ fn {{ fn_name }}({% if out_numel != 0 and op_numel != 1 %}out_index: u32{% endif %}) -> u32 {
3
+ {% if out_numel == 0 %}
4
+ return 0u;
5
+ {% elif op_numel == 1 %}
6
+ return 0u;
7
+ {% elif op_same %}
8
+ return out_index;
9
+ {% else %}
10
+ var offset = 0u;
11
+ {% for axis in range(outRank) %}
12
+ {% set op_axis = axis - (outRank - opRank) %}
13
+ {% if op_axis >= 0 and opShape[op_axis] != 1 %}
14
+ {% set c_stride = namespace(value=1) %}
15
+ {% for j in range(axis + 1, outRank) %}
16
+ {% set c_stride.value = c_stride.value * outShape[j] %}
17
+ {% endfor %}
18
+ {% set op_stride = namespace(value=1) %}
19
+ {% for j in range(op_axis + 1, opRank) %}
20
+ {% set op_stride.value = op_stride.value * opShape[j] %}
21
+ {% endfor %}
22
+ {% if c_stride.value == 1 %}
23
+ let coord{{ axis }} = out_index % {{ outShape[axis] }}u;
24
+ {% else %}
25
+ let coord{{ axis }} = (out_index / {{ c_stride.value }}u) % {{ outShape[axis] }}u;
26
+ {% endif %}
27
+ {% if op_stride.value == 1 %}
28
+ offset = offset + coord{{ axis }};
29
+ {% else %}
30
+ offset = offset + coord{{ axis }} * {{ op_stride.value }}u;
31
+ {% endif %}
32
+ {% endif %}
33
+ {% endfor %}
34
+ return offset;
35
+ {% endif %}
36
+ }
37
+ {%- endmacro %}{% macro broadcast_offset_call(fn_name, opShape, outShape, out_index) %}
38
+ {% set op_numel = namespace(value=1) %}
39
+ {% for d in opShape %}{% set op_numel.value = op_numel.value * d %}{% endfor %}
40
+ {% set out_numel = namespace(value=1) %}
41
+ {% for d in outShape %}{% set out_numel.value = out_numel.value * d %}{% endfor %}
42
+ {{ fn_name }}({% if out_numel.value != 0 and op_numel.value != 1 %}{{ out_index }}{% endif %})
43
+ {%- endmacro %}
44
+
45
+ {% if usesF16 %}
46
+ enable f16;
47
+ {% endif %}
48
+ {{ env.wgsl.resourceDeclarations }}
49
+
50
+ // Vec4 broadcast comparison op (Equal/Greater/GreaterOrEqual/Less/LessOrEqual),
51
+ // vectorized over the innermost output axis. Each thread writes
52
+ // a vec4<u32> of {0,1} results. The guard requires the output's innermost
53
+ // (stride-1) axis to be a multiple of 4, so a vec4 group of 4 consecutive
54
+ // outputs never crosses that axis. Per the broadcast rules, for the innermost
55
+ // axis each operand is one of: scalar (whole operand is one element), splat
56
+ // (innermost axis 1), or contiguous (innermost axis matches output). Operands
57
+ // stay scalar-typed bindings (4 coalesced scalar loads == one vec4 of bandwidth)
58
+ // and compare in their native type (no f32 widening — exact for int operands).
59
+ // Grid-strides a clamped dispatch so outputs beyond one dispatch dimension are covered.
60
+ {% set a_numel = namespace(value=1) %}
61
+ {% for d in source.aShape %}{% set a_numel.value = a_numel.value * d %}{% endfor %}
62
+ {% set b_numel = namespace(value=1) %}
63
+ {% for d in source.bShape %}{% set b_numel.value = b_numel.value * d %}{% endfor %}
64
+ {% set c_numel = namespace(value=1) %}
65
+ {% for d in source.cShape %}{% set c_numel.value = c_numel.value * d %}{% endfor %}
66
+ {% set a_same = namespace(value=(source.aRank == source.cRank)) %}
67
+ {% if a_same.value %}{% for axis in range(source.cRank) %}{% if source.aShape[axis] != source.cShape[axis] %}{% set a_same.value = false %}{% endif %}{% endfor %}{% endif %}
68
+ {% set b_same = namespace(value=(source.bRank == source.cRank)) %}
69
+ {% if b_same.value %}{% for axis in range(source.cRank) %}{% if source.bShape[axis] != source.cShape[axis] %}{% set b_same.value = false %}{% endif %}{% endfor %}{% endif %}
70
+ {% set a_inner = source.aShape[source.aRank - 1] if source.aRank >= 1 else 1 %}
71
+ {% set b_inner = source.bShape[source.bRank - 1] if source.bRank >= 1 else 1 %}
72
+ {% if a_numel.value == 1 %}{% set a_mode = "scalar" %}
73
+ {% elif a_inner == 1 %}{% set a_mode = "splat" %}
74
+ {% else %}{% set a_mode = "contig" %}{% endif %}
75
+ {% if b_numel.value == 1 %}{% set b_mode = "scalar" %}
76
+ {% elif b_inner == 1 %}{% set b_mode = "splat" %}
77
+ {% else %}{% set b_mode = "contig" %}{% endif %}
78
+
79
+ {% if a_mode != "scalar" %}
80
+ {{ offset_fn("a_offset", source.aShape, source.aRank, a_same.value, a_numel.value, source.cShape, source.cRank, c_numel.value) }}
81
+ {% endif %}
82
+
83
+ {% if b_mode != "scalar" %}
84
+ {{ offset_fn("b_offset", source.bShape, source.bRank, b_same.value, b_numel.value, source.cShape, source.cRank, c_numel.value) }}
85
+ {% endif %}
86
+
87
+ {% set OP = {"equal": "==", "greater": ">", "greaterOrEqual": ">=", "less": "<", "lessOrEqual": "<="}[source.op] %}
88
+ const WG: u32 = {{ tunables.WORKGROUP_SIZE }}u;
89
+
90
+ @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
91
+ fn main(
92
+ @builtin(global_invocation_id) gid: vec3<u32>,
93
+ @builtin(num_workgroups) nwg: vec3<u32>
94
+ ) {
95
+ let stride = nwg.x * WG;
96
+ for (var i4 = gid.x; i4 < params.count; i4 += stride) {
97
+ let base = i4 * 4u;
98
+ {% if a_mode == "scalar" %}
99
+ let av = vec4<{{ scalar }}>(a[0]);
100
+ {% elif a_mode == "splat" %}
101
+ let av = vec4<{{ scalar }}>(a[{{ broadcast_offset_call("a_offset", source.aShape, source.cShape, "base") }}]);
102
+ {% else %}
103
+ let ao = {{ broadcast_offset_call("a_offset", source.aShape, source.cShape, "base") }};
104
+ let av = vec4<{{ scalar }}>(a[ao], a[ao + 1u], a[ao + 2u], a[ao + 3u]);
105
+ {% endif %}
106
+ {% if b_mode == "scalar" %}
107
+ let bv = vec4<{{ scalar }}>(b[0]);
108
+ {% elif b_mode == "splat" %}
109
+ let bv = vec4<{{ scalar }}>(b[{{ broadcast_offset_call("b_offset", source.bShape, source.cShape, "base") }}]);
110
+ {% else %}
111
+ let bo = {{ broadcast_offset_call("b_offset", source.bShape, source.cShape, "base") }};
112
+ let bv = vec4<{{ scalar }}>(b[bo], b[bo + 1u], b[bo + 2u], b[bo + 3u]);
113
+ {% endif %}
114
+ c[i4] = select(vec4<u32>(0u), vec4<u32>(1u), av {{ OP }} bv);
115
+ }
116
+ }
build/webgpu/compare-broadcast.wgsl.jinja ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro flat_tail_open() %}
2
+ @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
3
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
4
+ // 2D-folded flat index: gid.y carries the high bits when the element count exceeds the
5
+ // maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills the rest into y).
6
+ let invocation = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
7
+ {% if source.itemsPerInvocation is defined %}
8
+ // Tail-safe scalar x4 keeps vector-like dispatch density without requiring
9
+ // the logical tensor length (or its storage binding) to be vec4 aligned.
10
+ let begin = invocation * {{ source.itemsPerInvocation }}u;
11
+ let end = min(begin + {{ source.itemsPerInvocation }}u, params.count);
12
+ for (var i = begin; i < end; i = i + 1u) {
13
+ {%- else %}
14
+ let i = invocation;
15
+ if (i >= params.count) {
16
+ return;
17
+ }
18
+ {%- endif %}
19
+ {% endmacro %}
20
+ {% macro flat_tail_close() %}
21
+ {% if source.itemsPerInvocation is defined %}
22
+ }
23
+ {% endif %}
24
+ {% endmacro %}
25
+
26
+ {% macro offset_fn(fn_name, opShape, opRank, op_same, op_numel, outShape, outRank, out_numel) %}
27
+ fn {{ fn_name }}({% if out_numel != 0 and op_numel != 1 %}out_index: u32{% endif %}) -> u32 {
28
+ {% if out_numel == 0 %}
29
+ return 0u;
30
+ {% elif op_numel == 1 %}
31
+ return 0u;
32
+ {% elif op_same %}
33
+ return out_index;
34
+ {% else %}
35
+ var offset = 0u;
36
+ {% for axis in range(outRank) %}
37
+ {% set op_axis = axis - (outRank - opRank) %}
38
+ {% if op_axis >= 0 and opShape[op_axis] != 1 %}
39
+ {% set c_stride = namespace(value=1) %}
40
+ {% for j in range(axis + 1, outRank) %}
41
+ {% set c_stride.value = c_stride.value * outShape[j] %}
42
+ {% endfor %}
43
+ {% set op_stride = namespace(value=1) %}
44
+ {% for j in range(op_axis + 1, opRank) %}
45
+ {% set op_stride.value = op_stride.value * opShape[j] %}
46
+ {% endfor %}
47
+ {% if c_stride.value == 1 %}
48
+ let coord{{ axis }} = out_index % {{ outShape[axis] }}u;
49
+ {% else %}
50
+ let coord{{ axis }} = (out_index / {{ c_stride.value }}u) % {{ outShape[axis] }}u;
51
+ {% endif %}
52
+ {% if op_stride.value == 1 %}
53
+ offset = offset + coord{{ axis }};
54
+ {% else %}
55
+ offset = offset + coord{{ axis }} * {{ op_stride.value }}u;
56
+ {% endif %}
57
+ {% endif %}
58
+ {% endfor %}
59
+ return offset;
60
+ {% endif %}
61
+ }
62
+ {%- endmacro %}{% macro broadcast_offset_call(fn_name, opShape, outShape, out_index) %}
63
+ {% set op_numel = namespace(value=1) %}
64
+ {% for d in opShape %}{% set op_numel.value = op_numel.value * d %}{% endfor %}
65
+ {% set out_numel = namespace(value=1) %}
66
+ {% for d in outShape %}{% set out_numel.value = out_numel.value * d %}{% endfor %}
67
+ {{ fn_name }}({% if out_numel.value != 0 and op_numel.value != 1 %}{{ out_index }}{% endif %})
68
+ {%- endmacro %}{% macro broadcast_offset_fn(fn_name, opShape, opRank, outShape, outRank) %}
69
+ {% set op_numel = namespace(value=1) %}
70
+ {% for d in opShape %}
71
+ {% set op_numel.value = op_numel.value * d %}
72
+ {% endfor %}
73
+ {% set out_numel = namespace(value=1) %}
74
+ {% for d in outShape %}
75
+ {% set out_numel.value = out_numel.value * d %}
76
+ {% endfor %}
77
+ {% set op_same = namespace(value=(opRank == outRank)) %}
78
+ {% if op_same.value %}
79
+ {% for axis in range(outRank) %}
80
+ {% if opShape[axis] != outShape[axis] %}
81
+ {% set op_same.value = false %}
82
+ {% endif %}
83
+ {% endfor %}
84
+ {% endif %}
85
+ {{ offset_fn(fn_name, opShape, opRank, op_same.value, op_numel.value, outShape, outRank, out_numel.value) }}
86
+ {%- endmacro %}{% macro binary_broadcast_offsets() %}
87
+ {{ broadcast_offset_fn("a_offset", source.aShape, source.aRank, source.cShape, source.cRank) }}
88
+
89
+ {{ broadcast_offset_fn("b_offset", source.bShape, source.bRank, source.cShape, source.cRank) }}
90
+ {%- endmacro %}
91
+
92
+ {% if usesF16 %}
93
+ enable f16;
94
+ {% endif %}
95
+ {{ env.wgsl.resourceDeclarations }}
96
+
97
+
98
+ {{ binary_broadcast_offsets() }}
99
+
100
+ {{ flat_tail_open() }}
101
+ c[i] = select(0u, 1u, a[{{ broadcast_offset_call("a_offset", source.aShape, source.cShape, "i") }}] < b[{{ broadcast_offset_call("b_offset", source.bShape, source.cShape, "i") }}]);
102
+ {{ flat_tail_close() -}}
103
+ }
build/webgpu/compare-vec4.wgsl.jinja ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% if usesF16 %}
2
+ enable f16;
3
+ {% endif %}
4
+ {{ env.wgsl.resourceDeclarations }}
5
+
6
+ @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
7
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
8
+ // 2D-folded flat index: gid.y carries the high bits when the element count exceeds the
9
+ // maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills the rest into y).
10
+ let i = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
11
+ if (i >= params.count) {
12
+ return;
13
+ }
14
+ let av = a[i];
15
+ let bv = b[i];
16
+ c[i] = select(vec4<u32>(0u), vec4<u32>(1u), av < bv);
17
+ }
build/webgpu/manifest.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "ai.onnx",
3
+ "name": "Less",
4
+ "sinceVersion": 13,
5
+ "description": "Performs an elementwise `less-than` comparison between tensors `A` and `B` with NumPy-style multidirectional broadcasting, producing a boolean result tensor `C`. Each output element is `true` where the corresponding element of `A` is strictly less than that of `B`.",
6
+ "inputs": [
7
+ { "role": "A", "dtype": "T", "description": "First input operand for the less-than comparison." },
8
+ { "role": "B", "dtype": "T", "description": "Second input operand for the less-than comparison." }
9
+ ],
10
+ "outputs": [
11
+ {
12
+ "role": "C",
13
+ "dtype": "B",
14
+ "rank": "max(ranks.A, ranks.B)",
15
+ "description": "Boolean result tensor; true where A < B.",
16
+ "shape": "broadcastShape(shapes.A, shapes.B)"
17
+ }
18
+ ],
19
+ "typeConstraints": { "T": ["float32", "float16", "int32", "int16", "uint32", "int8", "uint8"], "B": ["bool"] },
20
+ "args": {
21
+ "a": { "kind": "tensor", "semantic": "A", "role": "input" },
22
+ "b": { "kind": "tensor", "semantic": "B", "role": "input" },
23
+ "c": { "kind": "tensor", "semantic": "C", "role": "output" }
24
+ },
25
+ "tunables": { "WORKGROUP_SIZE": 256 },
26
+ "variants": [
27
+ {
28
+ "id": "same_shape_vec4",
29
+ "priority": 20,
30
+ "when": ["sameShape(shapes.A, shapes.C)", "sameShape(shapes.B, shapes.C)", "numel(shapes.C) > 0", "numel(shapes.C) % 4 == 0", "f16Ok(dtypes.T)"],
31
+ "constants": { "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"", "usesF16": "dtypes.T == \"f16\"" },
32
+ "passes": [
33
+ {
34
+ "id": "main",
35
+ "name": "Less.vec4",
36
+ "source": { "shader": "compare-vec4.wgsl.jinja", "inputs": { "op": "\"less\"" } },
37
+ "bindings": [
38
+ {
39
+ "name": "a",
40
+ "arg": "a",
41
+ "semantic": "A",
42
+ "buffer": { "type": "read-only-storage" },
43
+ "elementType": "$vectorScalar"
44
+ },
45
+ {
46
+ "name": "b",
47
+ "arg": "b",
48
+ "semantic": "B",
49
+ "buffer": { "type": "read-only-storage" },
50
+ "elementType": "$vectorScalar"
51
+ },
52
+ { "name": "c", "arg": "c", "semantic": "C", "buffer": { "type": "storage" }, "elementType": "vec4<u32>" },
53
+ {
54
+ "name": "params",
55
+ "semantic": "kernel.params",
56
+ "buffer": { "type": "uniform" },
57
+ "struct": {
58
+ "name": "Params",
59
+ "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.C) / 4" }]
60
+ }
61
+ }
62
+ ],
63
+ "dispatch": { "threads": "numel(shapes.C) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "id": "broadcast_vec4",
69
+ "when": ["ranks.A <= ranks.C", "ranks.B <= ranks.C", "ranks.C >= 1", "dim(shapes.C, ranks.C - 1) % 4 == 0", "numel(shapes.C) % 4 == 0", "numel(shapes.C) >= 4", "f16Ok(dtypes.T)"],
70
+ "constants": { "scalar": "dtypes.T", "usesF16": "dtypes.T == \"f16\"" },
71
+ "passes": [
72
+ {
73
+ "id": "main",
74
+ "name": "Less",
75
+ "source": {
76
+ "shader": "compare-broadcast-vec4.wgsl.jinja",
77
+ "inputs": {
78
+ "aShape": "shapes.A",
79
+ "bShape": "shapes.B",
80
+ "cShape": "shapes.C",
81
+ "aRank": "ranks.A",
82
+ "bRank": "ranks.B",
83
+ "cRank": "ranks.C",
84
+ "op": "\"less\""
85
+ }
86
+ },
87
+ "bindings": [
88
+ {
89
+ "name": "a",
90
+ "arg": "a",
91
+ "semantic": "A",
92
+ "buffer": { "type": "read-only-storage" },
93
+ "elementType": "$scalar"
94
+ },
95
+ {
96
+ "name": "b",
97
+ "arg": "b",
98
+ "semantic": "B",
99
+ "buffer": { "type": "read-only-storage" },
100
+ "elementType": "$scalar"
101
+ },
102
+ { "name": "c", "arg": "c", "semantic": "C", "buffer": { "type": "storage" }, "elementType": "vec4<u32>" },
103
+ {
104
+ "name": "params",
105
+ "semantic": "kernel.params",
106
+ "buffer": { "type": "uniform" },
107
+ "struct": {
108
+ "name": "Params",
109
+ "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.C) / 4" }]
110
+ }
111
+ }
112
+ ],
113
+ "dispatch": { "gridStride": "numel(shapes.C) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
114
+ }
115
+ ],
116
+ "priority": 10
117
+ },
118
+ {
119
+ "id": "broadcast",
120
+ "when": ["ranks.A <= ranks.C", "ranks.B <= ranks.C", "f16Ok(dtypes.T)"],
121
+ "constants": { "scalar": "dtypes.T", "usesF16": "dtypes.T == \"f16\"" },
122
+ "passes": [
123
+ {
124
+ "id": "main",
125
+ "name": "Less",
126
+ "source": {
127
+ "shader": "compare-broadcast.wgsl.jinja",
128
+ "inputs": {
129
+ "aShape": "shapes.A",
130
+ "bShape": "shapes.B",
131
+ "cShape": "shapes.C",
132
+ "aRank": "ranks.A",
133
+ "bRank": "ranks.B",
134
+ "cRank": "ranks.C",
135
+ "op": "\"less\""
136
+ }
137
+ },
138
+ "bindings": [
139
+ {
140
+ "name": "a",
141
+ "arg": "a",
142
+ "semantic": "A",
143
+ "buffer": { "type": "read-only-storage" },
144
+ "elementType": "$scalar"
145
+ },
146
+ {
147
+ "name": "b",
148
+ "arg": "b",
149
+ "semantic": "B",
150
+ "buffer": { "type": "read-only-storage" },
151
+ "elementType": "$scalar"
152
+ },
153
+ { "name": "c", "arg": "c", "semantic": "C", "buffer": { "type": "storage" }, "elementType": "u32" },
154
+ {
155
+ "name": "params",
156
+ "semantic": "kernel.params",
157
+ "buffer": { "type": "uniform" },
158
+ "struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.C)" }] }
159
+ }
160
+ ],
161
+ "dispatch": { "threads": "numel(shapes.C)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
162
+ }
163
+ ]
164
+ },
165
+ {
166
+ "id": "same_shape_scalar_x4",
167
+ "priority": 15,
168
+ "when": ["sameShape(shapes.A, shapes.C)", "sameShape(shapes.B, shapes.C)", "numel(shapes.C) > 0", "numel(shapes.C) % 4 != 0", "ranks.A <= ranks.C", "ranks.B <= ranks.C", "f16Ok(dtypes.T)"],
169
+ "constants": { "scalar": "dtypes.T", "usesF16": "dtypes.T == \"f16\"" },
170
+ "passes": [
171
+ {
172
+ "id": "main",
173
+ "name": "Less",
174
+ "source": {
175
+ "shader": "compare-broadcast.wgsl.jinja",
176
+ "inputs": {
177
+ "aShape": "shapes.A",
178
+ "bShape": "shapes.B",
179
+ "cShape": "shapes.C",
180
+ "aRank": "ranks.A",
181
+ "bRank": "ranks.B",
182
+ "cRank": "ranks.C",
183
+ "op": "\"less\"",
184
+ "itemsPerInvocation": 4
185
+ }
186
+ },
187
+ "bindings": [
188
+ {
189
+ "name": "a",
190
+ "arg": "a",
191
+ "semantic": "A",
192
+ "buffer": { "type": "read-only-storage" },
193
+ "elementType": "$scalar"
194
+ },
195
+ {
196
+ "name": "b",
197
+ "arg": "b",
198
+ "semantic": "B",
199
+ "buffer": { "type": "read-only-storage" },
200
+ "elementType": "$scalar"
201
+ },
202
+ { "name": "c", "arg": "c", "semantic": "C", "buffer": { "type": "storage" }, "elementType": "u32" },
203
+ {
204
+ "name": "params",
205
+ "semantic": "kernel.params",
206
+ "buffer": { "type": "uniform" },
207
+ "struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.C)" }] }
208
+ }
209
+ ],
210
+ "dispatch": { "threads": "ceilDiv(numel(shapes.C), 4)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
211
+ }
212
+ ]
213
+ }
214
+ ]
215
+ }
build/webgpu/metadata.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ai.onnx.Less",
3
+ "id": "_ai_onnx_less_webgpu_b3a83b0",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "backend": { "type": "webgpu" },
7
+ "digest": {
8
+ "algorithm": "sha256",
9
+ "files": {
10
+ "bench.json": "bi459h1j97iJXf9cdTyyrHoisesrs12uXVRMJmdV3jk=",
11
+ "compare-broadcast-vec4.wgsl.jinja": "tSx+Yubq+i8IwWTdoOppEsdRyIkK2mENofLE+InFA0w=",
12
+ "compare-broadcast.wgsl.jinja": "HVI9RZdy0/w305zyaf8ucuqiO7eZVyDwD4NIyvr5ouA=",
13
+ "compare-vec4.wgsl.jinja": "cXSOC920mmdSmQNgxaMiUZDh4jmFywSvCjPxMr8SAjI=",
14
+ "manifest.json": "ohxKA8+i8wSkSf6usZjszwgTM6UC/vDXuvvuSeZjOVQ=",
15
+ "test.json": "1ZrEwckIRspwkQp9fLSrgGzAcBEUXKJKNXIU81H+DYE="
16
+ }
17
+ },
18
+ "provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } },
19
+ "webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/ai.onnx.Less" }
20
+ }
build/webgpu/test.json ADDED
@@ -0,0 +1,536 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "op": "ai.onnx.Less",
3
+ "fixtureArrays": {
4
+ "onnx_backend_input_a": [1.764052391052246, 0.40015721321105957, 0.978738009929657, 2.2408931255340576, 1.8675580024719238, -0.9772778749465942, 0.9500884413719177, -0.15135720372200012, -0.10321885347366333, 0.4105985164642334, 0.14404356479644775, 1.4542734622955322, 0.7610377073287964, 0.12167501449584961, 0.44386324286460876, 0.3336743414402008, 1.4940791130065918, -0.2051582634449005, 0.3130677044391632, -0.8540957570075989, -2.5529897212982178, 0.653618574142456, 0.8644362092018127, -0.7421650290489197, 2.269754648208618, -1.4543657302856445, 0.04575851559638977, -0.18718385696411133, 1.5327792167663574, 1.4693588018417358, 0.154947429895401, 0.37816253304481506, -0.8877857327461243, -1.980796456336975, -0.34791216254234314, 0.15634897351264954, 1.2302906513214111, 1.202379822731018, -0.38732680678367615, -0.302302747964859, -1.0485529899597168, -1.420017957687378, -1.7062702178955078, 1.950775384902954, -0.5096521973609924, -0.4380742907524109, -1.2527953386306763, 0.7774903774261475, -1.6138978004455566, -0.21274028718471527, -0.8954665660858154, 0.38690251111984253, -0.5108051300048828, -1.18063223361969, -0.02818222902715206, 0.4283318817615509, 0.06651721894741058, 0.30247190594673157, -0.6343221068382263, -0.3627411723136902],
5
+ "broadcast_vec4_lhs_splat_lower_rank_input_b": [9, 10, 11, 10, 19, 20, 21, 20, 29, 30, 31, 30, 30, 20, 10, 0, 10, 20, 30, 40, 31, 29, 30, 10]
6
+ },
7
+ "cases": [
8
+ {
9
+ "name": "f32_negative_subnormal_less_than_zero_gpu_gap",
10
+ "skipGpu": {
11
+ "category": "permanent",
12
+ "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: Metal flushes float32 subnormals to zero, so a subnormal compares equal to 0 on GPU; cannot reproduce the strict-inequality result."
13
+ },
14
+ "provenance": {
15
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
16
+ "test": "MathOpTest.Less",
17
+ "notes": "A negative subnormal is strictly less than zero; flushing it to zero flips the predicate."
18
+ },
19
+ "inputs": {
20
+ "a": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [-1e-39, -1e-40, 0.0, 1e-40] } },
21
+ "b": { "dtype": "float32", "shape": [4], "data": { "kind": "constant", "value": 0.0 } }
22
+ },
23
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
24
+ },
25
+ {
26
+ "name": "f32_negative_subnormal_less_than_zero_scalar_gpu_gap",
27
+ "skipGpu": {
28
+ "category": "permanent",
29
+ "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: Metal flushes float32 subnormals to zero, so a subnormal compares equal to 0 on GPU; cannot reproduce the strict-inequality result."
30
+ },
31
+ "provenance": {
32
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
33
+ "test": "MathOpTest.Less",
34
+ "notes": "Scalar-path companion: negative subnormals are strictly less than zero and must keep mask lanes true."
35
+ },
36
+ "inputs": {
37
+ "a": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [-1e-40, 0.0, 1e-40] } },
38
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "constant", "value": 0.0 } }
39
+ },
40
+ "outputs": { "c": { "dtype": "bool", "shape": [3], "tolerance": 0 } }
41
+ },
42
+ {
43
+ "name": "broadcast",
44
+ "inputs": {
45
+ "a": {
46
+ "dtype": "float32",
47
+ "shape": [2, 3],
48
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] }
49
+ },
50
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [2.0, 2.0, 5.0] } }
51
+ },
52
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 3] } }
53
+ },
54
+ {
55
+ "name": "ort_int16_scalar_rhs",
56
+ "provenance": {
57
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
58
+ "test": "MathOpTest.Less_int16_Scalar1"
59
+ },
60
+ "inputs": {
61
+ "a": { "dtype": "int16", "shape": [4], "data": { "kind": "values", "values": [1, 0, 2, -1] } },
62
+ "b": { "dtype": "int16", "shape": [1], "data": { "kind": "values", "values": [1] } }
63
+ },
64
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
65
+ },
66
+ {
67
+ "name": "rank0_scalar_scalar_output",
68
+ "inputs": {
69
+ "a": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [-1.0] } },
70
+ "b": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [0.0] } }
71
+ },
72
+ "outputs": { "c": { "dtype": "bool", "shape": [], "tolerance": 0 } }
73
+ },
74
+ {
75
+ "name": "int32_exact_above_float24",
76
+ "inputs": {
77
+ "a": {
78
+ "dtype": "int32",
79
+ "shape": [4],
80
+ "data": { "kind": "values", "values": [16777216, 16777217, -16777217, -16777216] }
81
+ },
82
+ "b": {
83
+ "dtype": "int32",
84
+ "shape": [4],
85
+ "data": { "kind": "values", "values": [16777217, 16777216, -16777216, -16777217] }
86
+ }
87
+ },
88
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
89
+ },
90
+ {
91
+ "name": "ort_int8_scalar_rhs",
92
+ "provenance": {
93
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
94
+ "test": "MathOpTest.Less_int8_Scalar1"
95
+ },
96
+ "inputs": {
97
+ "a": { "dtype": "int8", "shape": [4], "data": { "kind": "values", "values": [1, 0, 2, -1] } },
98
+ "b": { "dtype": "int8", "shape": [1], "data": { "kind": "values", "values": [1] } }
99
+ },
100
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
101
+ },
102
+ {
103
+ "name": "ort_float_vector",
104
+ "provenance": {
105
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
106
+ "test": "MathOpTest.Less"
107
+ },
108
+ "inputs": {
109
+ "a": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [1.0, 0.0, -1.0, -1.0] } },
110
+ "b": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [1.0, 1.0, 2.0, -1.0] } }
111
+ },
112
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
113
+ },
114
+ {
115
+ "name": "ort_float_scalar_lhs",
116
+ "provenance": {
117
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
118
+ "test": "MathOpTest.Less_Scalar0"
119
+ },
120
+ "inputs": {
121
+ "a": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.0] } },
122
+ "b": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [1.0, 1.5, 2.0, -1.0] } }
123
+ },
124
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
125
+ },
126
+ {
127
+ "name": "ort_float_scalar_rhs",
128
+ "provenance": {
129
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
130
+ "test": "MathOpTest.Less_Scalar1"
131
+ },
132
+ "inputs": {
133
+ "a": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [1.0, 0.5, 2.0, -1.0] } },
134
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.0] } }
135
+ },
136
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
137
+ },
138
+ {
139
+ "name": "ort_uint8_scalar_rhs",
140
+ "provenance": {
141
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
142
+ "test": "MathOpTest.Less_uint8_Scalar1"
143
+ },
144
+ "inputs": {
145
+ "a": { "dtype": "uint8", "shape": [4], "data": { "kind": "values", "values": [1, 0, 2, 3] } },
146
+ "b": { "dtype": "uint8", "shape": [1], "data": { "kind": "values", "values": [2] } }
147
+ },
148
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
149
+ },
150
+ {
151
+ "name": "ort_uint32_scalar_rhs",
152
+ "provenance": {
153
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
154
+ "test": "MathOpTest.Less_uint32_Scalar1"
155
+ },
156
+ "inputs": {
157
+ "a": { "dtype": "uint32", "shape": [4], "data": { "kind": "values", "values": [1, 0, 2, 3] } },
158
+ "b": { "dtype": "uint32", "shape": [1], "data": { "kind": "values", "values": [2] } }
159
+ },
160
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
161
+ },
162
+ {
163
+ "name": "nan_comparisons_are_false",
164
+ "inputs": {
165
+ "a": {
166
+ "dtype": "float32",
167
+ "shape": [4],
168
+ "data": { "kind": "values", "values": ["NaN", 1.0, "Infinity", "-Infinity"] }
169
+ },
170
+ "b": {
171
+ "dtype": "float32",
172
+ "shape": [4],
173
+ "data": { "kind": "values", "values": [0.0, "NaN", "Infinity", "-Infinity"] }
174
+ }
175
+ },
176
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
177
+ },
178
+ {
179
+ "name": "ort_int32_broadcast_ab",
180
+ "provenance": {
181
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
182
+ "test": "MathOpTest.Less_broadcastAB"
183
+ },
184
+ "inputs": {
185
+ "a": {
186
+ "dtype": "int32",
187
+ "shape": [4, 2],
188
+ "data": { "kind": "values", "values": [10, 11, 12, 13, 14, 15, 16, 17] }
189
+ },
190
+ "b": { "dtype": "int32", "shape": [2], "data": { "kind": "values", "values": [15, 7] } }
191
+ },
192
+ "outputs": { "c": { "dtype": "bool", "shape": [4, 2], "tolerance": 0 } }
193
+ },
194
+ {
195
+ "name": "ort_int32_broadcast_ba",
196
+ "provenance": {
197
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
198
+ "test": "MathOpTest.Less_broadcastBA"
199
+ },
200
+ "inputs": {
201
+ "a": { "dtype": "int32", "shape": [2], "data": { "kind": "values", "values": [15, 7] } },
202
+ "b": {
203
+ "dtype": "int32",
204
+ "shape": [4, 2],
205
+ "data": { "kind": "values", "values": [10, 11, 12, 13, 14, 15, 16, 17] }
206
+ }
207
+ },
208
+ "outputs": { "c": { "dtype": "bool", "shape": [4, 2], "tolerance": 0 } }
209
+ },
210
+ {
211
+ "name": "ort_int32_multidirectional_broadcast_ab",
212
+ "provenance": {
213
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
214
+ "test": "MathOpTest.Less_multidirectional_broadcastAB"
215
+ },
216
+ "inputs": {
217
+ "a": { "dtype": "int32", "shape": [4, 1], "data": { "kind": "values", "values": [10, 11, 12, 13] } },
218
+ "b": { "dtype": "int32", "shape": [2], "data": { "kind": "values", "values": [15, 7] } }
219
+ },
220
+ "outputs": { "c": { "dtype": "bool", "shape": [4, 2], "tolerance": 0 } }
221
+ },
222
+ {
223
+ "name": "ort_int32_multidirectional_broadcast_ba",
224
+ "provenance": {
225
+ "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
226
+ "test": "MathOpTest.Less_multidirectional_broadcastBA"
227
+ },
228
+ "inputs": {
229
+ "a": { "dtype": "int32", "shape": [2], "data": { "kind": "values", "values": [15, 7] } },
230
+ "b": { "dtype": "int32", "shape": [4, 1], "data": { "kind": "values", "values": [10, 11, 12, 13] } }
231
+ },
232
+ "outputs": { "c": { "dtype": "bool", "shape": [4, 2], "tolerance": 0 } }
233
+ },
234
+ {
235
+ "name": "onnx_backend_bcast_float32_rank3",
236
+ "provenance": {
237
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_less_bcast",
238
+ "test": "test_less_bcast"
239
+ },
240
+ "inputs": {
241
+ "a": {
242
+ "dtype": "float32",
243
+ "shape": [3, 4, 5],
244
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_input_a" } }
245
+ },
246
+ "b": {
247
+ "dtype": "float32",
248
+ "shape": [5],
249
+ "data": {
250
+ "kind": "values",
251
+ "values": [-0.6724604368209839, -0.35955315828323364, -0.8131462931632996, -1.7262825965881348, 0.17742614448070526]
252
+ }
253
+ }
254
+ },
255
+ "outputs": { "c": { "dtype": "bool", "shape": [3, 4, 5], "tolerance": 0 } }
256
+ },
257
+ {
258
+ "name": "onnx_backend_less",
259
+ "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_less", "test": "test_less" },
260
+ "inputs": {
261
+ "a": {
262
+ "dtype": "float32",
263
+ "shape": [3, 4, 5],
264
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_input_a" } }
265
+ },
266
+ "b": {
267
+ "dtype": "float32",
268
+ "shape": [3, 4, 5],
269
+ "data": {
270
+ "kind": "values",
271
+ "values": [-0.6724604368209839, -0.35955315828323364, -0.8131462931632996, -1.7262825965881348, 0.17742614448070526, -0.4017809331417084, -1.630198359489441, 0.46278226375579834, -0.9072983860969543, 0.05194539576768875, 0.7290905714035034, 0.12898291647434235, 1.1394007205963135, -1.234825849533081, 0.4023416340351105, -0.6848101019859314, -0.8707971572875977, -0.5788496732711792, -0.3115525245666504, 0.056165341287851334, -1.1651498079299927, 0.9008265137672424, 0.4656624495983124, -1.5362436771392822, 1.4882521629333496, 1.895889163017273, 1.1787796020507812, -0.1799248307943344, -1.0707526206970215, 1.0544517040252686, -0.4031769335269928, 1.222445011138916, 0.2082749754190445, 0.9766390323638916, 0.3563663959503174, 0.7065731883049011, 0.01050002034753561, 1.7858705520629883, 0.12691208720207214, 0.4019893705844879, 1.8831506967544556, -1.3477590084075928, -1.2704850435256958, 0.969396710395813, -1.1731233596801758, 1.9436211585998535, -0.4136189818382263, -0.747454822063446, 1.922942042350769, 1.4805147647857666, 1.8675589561462402, 0.9060446619987488, -0.8612256646156311, 1.910064935684204, -0.26800337433815, 0.8024563789367676, 0.9472519755363464, -0.15501008927822113, 0.6140793561935425, 0.922206699848175]
272
+ }
273
+ }
274
+ },
275
+ "outputs": { "c": { "dtype": "bool", "shape": [3, 4, 5], "tolerance": 0 } }
276
+ },
277
+ {
278
+ "name": "onnx_backend_less_int8",
279
+ "provenance": {
280
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_less_int8",
281
+ "test": "test_less_int8"
282
+ },
283
+ "inputs": {
284
+ "a": {
285
+ "dtype": "int8",
286
+ "shape": [3, 4, 5],
287
+ "data": {
288
+ "kind": "values",
289
+ "values": [0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 2, 0, 0, 1, -1, 0, 0, 1, 0, 0, 0, 0, 1, -1, -1, 0, 0, 1, 0, 0, -1, 0, -1, -1, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0]
290
+ }
291
+ },
292
+ "b": {
293
+ "dtype": "int8",
294
+ "shape": [3, 4, 5],
295
+ "data": {
296
+ "kind": "values",
297
+ "values": [0, -1, 0, -2, 0, -1, -1, 0, 0, 1, -1, 0, 0, -1, 0, 0, 0, 0, 2, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 1, -2, 0, 0]
298
+ }
299
+ }
300
+ },
301
+ "outputs": { "c": { "dtype": "bool", "shape": [3, 4, 5], "tolerance": 0 } }
302
+ },
303
+ {
304
+ "name": "onnx_backend_less_uint8",
305
+ "provenance": {
306
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_less_uint8",
307
+ "test": "test_less_uint8"
308
+ },
309
+ "inputs": {
310
+ "a": {
311
+ "dtype": "uint8",
312
+ "shape": [3, 4, 5],
313
+ "data": {
314
+ "kind": "values",
315
+ "values": [13, 0, 18, 7, 12, 14, 19, 8, 13, 17, 17, 10, 22, 19, 7, 12, 13, 2, 11, 12, 17, 13, 6, 14, 15, 7, 5, 21, 17, 16, 3, 18, 9, 10, 0, 18, 0, 20, 13, 6, 10, 23, 19, 1, 13, 6, 23, 23, 12, 23, 20, 14, 1, 1, 16, 12, 17, 10, 20, 21]
316
+ }
317
+ },
318
+ "b": {
319
+ "dtype": "uint8",
320
+ "shape": [3, 4, 5],
321
+ "data": {
322
+ "kind": "values",
323
+ "values": [18, 21, 10, 19, 0, 5, 21, 5, 4, 18, 23, 11, 20, 12, 20, 10, 16, 2, 12, 2, 23, 0, 7, 6, 6, 16, 18, 9, 3, 0, 10, 2, 18, 18, 20, 13, 1, 12, 0, 9, 22, 7, 19, 21, 1, 21, 3, 19, 21, 4, 2, 5, 16, 11, 18, 4, 4, 1, 23, 9]
324
+ }
325
+ }
326
+ },
327
+ "outputs": { "c": { "dtype": "bool", "shape": [3, 4, 5], "tolerance": 0 } }
328
+ },
329
+ {
330
+ "name": "onnx_backend_less_uint32",
331
+ "provenance": {
332
+ "source": "cmake/external/onnx/onnx/backend/test/data/node/test_less_uint32",
333
+ "test": "test_less_uint32"
334
+ },
335
+ "inputs": {
336
+ "a": {
337
+ "dtype": "uint32",
338
+ "shape": [3, 4, 5],
339
+ "data": {
340
+ "kind": "values",
341
+ "values": [19, 2, 12, 9, 19, 8, 5, 20, 21, 11, 1, 11, 15, 12, 15, 12, 21, 18, 13, 12, 9, 21, 6, 4, 16, 8, 5, 15, 5, 5, 17, 0, 16, 16, 0, 10, 12, 0, 7, 22, 19, 5, 4, 19, 4, 5, 12, 17, 19, 12, 6, 7, 20, 16, 0, 23, 15, 10, 3, 3]
342
+ }
343
+ },
344
+ "b": {
345
+ "dtype": "uint32",
346
+ "shape": [3, 4, 5],
347
+ "data": {
348
+ "kind": "values",
349
+ "values": [16, 16, 9, 20, 20, 5, 16, 17, 21, 9, 12, 15, 6, 14, 1, 4, 16, 4, 7, 23, 14, 7, 22, 2, 22, 16, 15, 15, 18, 11, 23, 14, 7, 2, 22, 17, 3, 7, 13, 16, 5, 4, 21, 13, 5, 19, 11, 8, 0, 17, 5, 4, 1, 5, 16, 6, 8, 22, 19, 4]
350
+ }
351
+ }
352
+ },
353
+ "outputs": { "c": { "dtype": "bool", "shape": [3, 4, 5], "tolerance": 0 } }
354
+ },
355
+ {
356
+ "name": "empty_input_zero_dim",
357
+ "inputs": {
358
+ "a": { "dtype": "float32", "shape": [2, 0], "data": { "kind": "values", "values": [] } },
359
+ "b": { "dtype": "float32", "shape": [0], "data": { "kind": "values", "values": [] } }
360
+ },
361
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 0], "tolerance": 0 } }
362
+ },
363
+ {
364
+ "name": "broadcast_vec4_inner4_gpu",
365
+ "provenance": {
366
+ "source": "synthetic",
367
+ "test": "broadcast_vec4 inner-dim %4==0 coverage",
368
+ "notes": "Broadcasts A=[2,1,4] and B to C with innermost extent four. Exercises vec4 broadcast indexing and verifies that the grid-stride count is expressed in vec4 groups (numel(C)/4), including bounds-safe iteration across six groups."
369
+ },
370
+ "inputs": {
371
+ "a": {
372
+ "dtype": "float32",
373
+ "shape": [2, 1, 4],
374
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] }
375
+ },
376
+ "b": {
377
+ "dtype": "float32",
378
+ "shape": [2, 3, 4],
379
+ "data": {
380
+ "kind": "values",
381
+ "values": [0.0, 2.0, 4.0, 4.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 4.0, 7.0, 6.0, 9.0, 9.0, 9.0, 9.0, 9.0]
382
+ }
383
+ }
384
+ },
385
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 3, 4], "tolerance": 0 } }
386
+ },
387
+ {
388
+ "name": "f16_same_shape",
389
+ "inputs": {
390
+ "a": {
391
+ "dtype": "float16",
392
+ "shape": [8],
393
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, "NaN", "Infinity", "-Infinity", -2.5, 65504.0] }
394
+ },
395
+ "b": {
396
+ "dtype": "float16",
397
+ "shape": [8],
398
+ "data": { "kind": "values", "values": [2.0, 2.0, 1.0, 1.0, 1.0, 1.0, -2.5, 65504.0] }
399
+ }
400
+ },
401
+ "outputs": { "c": { "dtype": "bool", "shape": [8] } }
402
+ },
403
+ {
404
+ "name": "f16_scalar_rhs",
405
+ "inputs": {
406
+ "a": {
407
+ "dtype": "float16",
408
+ "shape": [8],
409
+ "data": { "kind": "values", "values": [-2.0, -1.0, 0.0, 1.0, 2.0, 3.0, "NaN", "Infinity"] }
410
+ },
411
+ "b": { "dtype": "float16", "shape": [1], "data": { "kind": "values", "values": [1.0] } }
412
+ },
413
+ "outputs": { "c": { "dtype": "bool", "shape": [8] } }
414
+ },
415
+ {
416
+ "name": "int8_extremes_less",
417
+ "inputs": {
418
+ "a": { "dtype": "int8", "shape": [6], "data": { "kind": "values", "values": [-128, 127, -128, 127, 0, -1] } },
419
+ "b": { "dtype": "int8", "shape": [6], "data": { "kind": "values", "values": [127, -128, -128, 127, -128, 0] } }
420
+ },
421
+ "outputs": { "c": { "dtype": "bool", "shape": [6], "tolerance": 0 } }
422
+ },
423
+ {
424
+ "name": "broadcast_scalar_path_odd_inner_dim",
425
+ "inputs": {
426
+ "a": {
427
+ "dtype": "int32",
428
+ "shape": [4, 5],
429
+ "data": { "kind": "values", "values": [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 10, 8, 6, 4, 2, 9, 7, 5, 3, 1] }
430
+ },
431
+ "b": { "dtype": "int32", "shape": [5], "data": { "kind": "values", "values": [5, 5, 5, 5, 5] } }
432
+ },
433
+ "outputs": { "c": { "dtype": "bool", "shape": [4, 5], "tolerance": 0 } }
434
+ },
435
+ {
436
+ "name": "f32_broadcast_odd_inner_dim_4x17",
437
+ "provenance": {
438
+ "notes": "Compact f32 sibling for the odd-inner broadcast benchmark; preserves the [rows, odd] x [odd] shape family without benchmark-scale rows."
439
+ },
440
+ "inputs": {
441
+ "a": {
442
+ "dtype": "float32",
443
+ "shape": [4, 17],
444
+ "data": { "kind": "fillFloat32", "sinStep": 0.037, "cosStep": 0.019, "scale": 0.5 }
445
+ },
446
+ "b": {
447
+ "dtype": "float32",
448
+ "shape": [17],
449
+ "data": { "kind": "fillFloat32", "sinStep": 0.011, "cosStep": 0.043, "scale": 0.5 }
450
+ }
451
+ },
452
+ "outputs": { "c": { "dtype": "bool", "shape": [4, 17], "tolerance": 0 } }
453
+ },
454
+ {
455
+ "name": "uint8_extremes_less",
456
+ "inputs": {
457
+ "a": { "dtype": "uint8", "shape": [4], "data": { "kind": "values", "values": [0, 255, 128, 127] } },
458
+ "b": { "dtype": "uint8", "shape": [4], "data": { "kind": "values", "values": [255, 0, 127, 128] } }
459
+ },
460
+ "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
461
+ },
462
+ {
463
+ "name": "rank7_broadcast_scalar_tail",
464
+ "inputs": {
465
+ "a": {
466
+ "dtype": "float32",
467
+ "shape": [2, 1, 2, 1, 2, 1, 3],
468
+ "data": { "kind": "fillFloat32", "sinStep": 0.11, "cosStep": 0.23 }
469
+ },
470
+ "b": {
471
+ "dtype": "float32",
472
+ "shape": [1, 2, 1, 2, 1, 2, 1],
473
+ "data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.07 }
474
+ }
475
+ },
476
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 2, 2, 2, 2, 2, 3], "tolerance": 0 } }
477
+ },
478
+ {
479
+ "name": "broadcast_vec4_lhs_splat_lower_rank",
480
+ "provenance": {
481
+ "source": "authored for render coverage",
482
+ "test": "compare-broadcast-vec4 lhs splat arm",
483
+ "notes": "A is rank 2 against a rank 3 output and its innermost axis is 1, so compare-broadcast-vec4 renders `a_same` false straight from the rank test and takes the a_mode == \"splat\" branch, which reads one A element per vec4 group instead of four contiguous ones. Every other vec4-eligible case has A either the same rank as C (contiguous) or a single element (scalar), so neither the lower-rank A arm nor the A-splat arm had ever rendered. Each row of A holds a different value and B differs at every position, so a wrong a_offset changes the result."
484
+ },
485
+ "inputs": {
486
+ "a": { "dtype": "float32", "shape": [3, 1], "data": { "kind": "values", "values": [10.0, 20.0, 30.0] } },
487
+ "b": {
488
+ "dtype": "float32",
489
+ "shape": [2, 3, 4],
490
+ "data": {
491
+ "kind": "values",
492
+ "values": { "$ref": "#/fixtureArrays/broadcast_vec4_lhs_splat_lower_rank_input_b" }
493
+ }
494
+ }
495
+ },
496
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 3, 4], "tolerance": 0 } }
497
+ },
498
+ {
499
+ "name": "broadcast_vec4_rhs_splat_lower_rank",
500
+ "provenance": {
501
+ "source": "authored for render coverage",
502
+ "test": "compare-broadcast-vec4 rhs splat arm",
503
+ "notes": "B is rank 2 with innermost axis 1 against a rank-3 output, so each vec4 output group broadcasts one B value while A remains contiguous. This mirrors the corresponding left-hand splat case."
504
+ },
505
+ "inputs": {
506
+ "a": {
507
+ "dtype": "float32",
508
+ "shape": [2, 3, 4],
509
+ "data": {
510
+ "kind": "values",
511
+ "values": { "$ref": "#/fixtureArrays/broadcast_vec4_lhs_splat_lower_rank_input_b" }
512
+ }
513
+ },
514
+ "b": { "dtype": "float32", "shape": [3, 1], "data": { "kind": "values", "values": [10.0, 20.0, 30.0] } }
515
+ },
516
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 3, 4], "tolerance": 0 } }
517
+ },
518
+ {
519
+ "name": "broadcast_vec4_true_scalar_lhs",
520
+ "provenance": {
521
+ "source": "authored for render coverage",
522
+ "test": "compare-broadcast-vec4 rank-0 lhs arm",
523
+ "notes": "A is a true rank-0 scalar, so `source.aRank >= 1` is false and compare-broadcast-vec4 takes the left-hand scalar arm. C's innermost dimension is 4 and numel is 8, selecting broadcast_vec4 while distinguishing A-scalar from B-scalar indexing."
524
+ },
525
+ "inputs": {
526
+ "a": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [20.0] } },
527
+ "b": {
528
+ "dtype": "float32",
529
+ "shape": [2, 4],
530
+ "data": { "kind": "values", "values": [10.0, 20.0, 30.0, 20.0, -5.0, 20.0, 25.0, 0.0] }
531
+ }
532
+ },
533
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 4], "tolerance": 0 } }
534
+ }
535
+ ]
536
+ }