Xenova HF Staff commited on
Commit
0356b3a
·
verified ·
1 Parent(s): dd997f7

sync 91d990483a17

Browse files
README.md CHANGED
@@ -18,16 +18,16 @@ See the [ONNX `Less` spec](https://onnx.ai/onnx/operators/onnx__Less.html) for t
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
 
@@ -38,7 +38,7 @@ See the [ONNX `Less` spec](https://onnx.ai/onnx/operators/onnx__Less.html) for t
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
@@ -48,10 +48,14 @@ See the [ONNX `Less` spec](https://onnx.ai/onnx/operators/onnx__Less.html) for t
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
 
 
18
 
19
  ## Inputs
20
 
21
+ | Name | Upstream name | 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 | Upstream name | 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
 
 
38
 
39
  ## Files
40
 
41
+ - [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, per-variant templates, 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
 
48
 
49
  ## Use with `@huggingface/kernels`
50
 
51
+ ```sh
52
+ npm install --save-exact @huggingface/kernels@0.0.1-preview.2
53
+ ```
54
+
55
+ Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
56
 
57
  The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
58
+ It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
59
 
60
  Replace each `*Data` placeholder with a typed array containing the corresponding input data.
61
 
build/webgpu/bench.json CHANGED
@@ -1,5 +1,4 @@
1
  {
2
- "op": "ai.onnx.Less",
3
  "tunableSpace": { "WORKGROUP_SIZE": [64, 128, 256] },
4
  "cases": [
5
  {
 
1
  {
 
2
  "tunableSpace": { "WORKGROUP_SIZE": [64, 128, 256] },
3
  "cases": [
4
  {
build/webgpu/compare-broadcast-vec4.wgsl.jinja CHANGED
@@ -42,33 +42,29 @@ fn {{ fn_name }}({% if out_numel != 0 and op_numel != 1 %}out_index: u32{% endif
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 %}
@@ -77,14 +73,14 @@ enable f16;
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 }})
@@ -98,17 +94,17 @@ fn main(
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);
 
42
  {{ fn_name }}({% if out_numel.value != 0 and op_numel.value != 1 %}{{ out_index }}{% endif %})
43
  {%- endmacro %}
44
 
 
 
 
45
  {{ env.wgsl.resourceDeclarations }}
46
 
47
+ // Broadcast comparison vectorized over the innermost output axis. Each thread
48
+ // writes a vec4<u32> of {0,1} results. This specialization requires the output's innermost
 
49
  // (stride-1) axis to be a multiple of 4, so a vec4 group of 4 consecutive
50
  // outputs never crosses that axis. Per the broadcast rules, for the innermost
51
  // axis each operand is one of: scalar (whole operand is one element), splat
52
  // (innermost axis 1), or contiguous (innermost axis matches output). Operands
53
+ // stay scalar-typed bindings; contiguous operands are loaded from four
54
+ // consecutive addresses. Comparisons use the native type with no f32 widening.
55
  // Grid-strides a clamped dispatch so outputs beyond one dispatch dimension are covered.
56
  {% set a_numel = namespace(value=1) %}
57
+ {% for d in aShape %}{% set a_numel.value = a_numel.value * d %}{% endfor %}
58
  {% set b_numel = namespace(value=1) %}
59
+ {% for d in bShape %}{% set b_numel.value = b_numel.value * d %}{% endfor %}
60
  {% set c_numel = namespace(value=1) %}
61
+ {% for d in cShape %}{% set c_numel.value = c_numel.value * d %}{% endfor %}
62
+ {% set a_same = namespace(value=(aRank == cRank)) %}
63
+ {% if a_same.value %}{% for axis in range(cRank) %}{% if aShape[axis] != cShape[axis] %}{% set a_same.value = false %}{% endif %}{% endfor %}{% endif %}
64
+ {% set b_same = namespace(value=(bRank == cRank)) %}
65
+ {% if b_same.value %}{% for axis in range(cRank) %}{% if bShape[axis] != cShape[axis] %}{% set b_same.value = false %}{% endif %}{% endfor %}{% endif %}
66
+ {% set a_inner = aShape[aRank - 1] if aRank >= 1 else 1 %}
67
+ {% set b_inner = bShape[bRank - 1] if bRank >= 1 else 1 %}
68
  {% if a_numel.value == 1 %}{% set a_mode = "scalar" %}
69
  {% elif a_inner == 1 %}{% set a_mode = "splat" %}
70
  {% else %}{% set a_mode = "contig" %}{% endif %}
 
73
  {% else %}{% set b_mode = "contig" %}{% endif %}
74
 
75
  {% if a_mode != "scalar" %}
76
+ {{ offset_fn("a_offset", aShape, aRank, a_same.value, a_numel.value, cShape, cRank, c_numel.value) }}
77
  {% endif %}
78
 
79
  {% if b_mode != "scalar" %}
80
+ {{ offset_fn("b_offset", bShape, bRank, b_same.value, b_numel.value, cShape, cRank, c_numel.value) }}
81
  {% endif %}
82
 
83
+ {% set OP = {"equal": "==", "greater": ">", "greaterOrEqual": ">=", "less": "<", "lessOrEqual": "<="}[op] %}
84
  const WG: u32 = {{ tunables.WORKGROUP_SIZE }}u;
85
 
86
  @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
 
94
  {% if a_mode == "scalar" %}
95
  let av = vec4<{{ scalar }}>(a[0]);
96
  {% elif a_mode == "splat" %}
97
+ let av = vec4<{{ scalar }}>(a[{{ broadcast_offset_call("a_offset", aShape, cShape, "base") }}]);
98
  {% else %}
99
+ let ao = {{ broadcast_offset_call("a_offset", aShape, cShape, "base") }};
100
  let av = vec4<{{ scalar }}>(a[ao], a[ao + 1u], a[ao + 2u], a[ao + 3u]);
101
  {% endif %}
102
  {% if b_mode == "scalar" %}
103
  let bv = vec4<{{ scalar }}>(b[0]);
104
  {% elif b_mode == "splat" %}
105
+ let bv = vec4<{{ scalar }}>(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "base") }}]);
106
  {% else %}
107
+ let bo = {{ broadcast_offset_call("b_offset", bShape, cShape, "base") }};
108
  let bv = vec4<{{ scalar }}>(b[bo], b[bo + 1u], b[bo + 2u], b[bo + 3u]);
109
  {% endif %}
110
  c[i4] = select(vec4<u32>(0u), vec4<u32>(1u), av {{ OP }} bv);
build/webgpu/compare-broadcast.wgsl.jinja CHANGED
@@ -1,13 +1,14 @@
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
  // Tail-safe scalar x4 keeps vector-like dispatch density without requiring
8
  // the logical tensor length (or its storage binding) to be vec4 aligned.
9
- let begin = invocation * {{ source.itemsPerInvocation }}u;
10
- let end = min(begin + {{ source.itemsPerInvocation }}u, params.count);
 
11
  for (var i = begin; i < end; i = i + 1u) {
12
  {%- endmacro %}
13
  {% macro flat_tail_close() %}
@@ -75,20 +76,23 @@ fn {{ fn_name }}({% if out_numel != 0 and op_numel != 1 %}out_index: u32{% endif
75
  {% endif %}
76
  {{ offset_fn(fn_name, opShape, opRank, op_same.value, op_numel.value, outShape, outRank, out_numel.value) }}
77
  {%- endmacro %}{% macro binary_broadcast_offsets() %}
78
- {{ broadcast_offset_fn("a_offset", source.aShape, source.aRank, source.cShape, source.cRank) }}
 
 
 
 
 
 
79
 
80
- {{ broadcast_offset_fn("b_offset", source.bShape, source.bRank, source.cShape, source.cRank) }}
81
  {%- endmacro %}
82
 
83
- {% if usesF16 %}
84
- enable f16;
85
- {% endif %}
86
  {{ env.wgsl.resourceDeclarations }}
87
 
88
 
89
  {{ binary_broadcast_offsets() }}
90
 
91
  {{ flat_tail_open() }}
92
- 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") }}]);
93
  {{ flat_tail_close() -}}
94
  }
 
1
  {% macro flat_tail_open() %}
2
  @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
3
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
4
  // 2D-folded flat index: gid.y carries the high bits when the element count exceeds the
5
+ // dispatch's per-axis workgroup fold width (the dispatch caps x and spills the rest into y).
6
+ let invocation = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ tunables.WORKGROUP_SIZE }}u;
7
  // Tail-safe scalar x4 keeps vector-like dispatch density without requiring
8
  // the logical tensor length (or its storage binding) to be vec4 aligned.
9
+ {% set itemsPerInvocation = itemsPerInvocation if itemsPerInvocation is defined else 4 %}
10
+ let begin = invocation * {{ itemsPerInvocation }}u;
11
+ let end = min(begin + {{ itemsPerInvocation }}u, params.count);
12
  for (var i = begin; i < end; i = i + 1u) {
13
  {%- endmacro %}
14
  {% macro flat_tail_close() %}
 
76
  {% endif %}
77
  {{ offset_fn(fn_name, opShape, opRank, op_same.value, op_numel.value, outShape, outRank, out_numel.value) }}
78
  {%- endmacro %}{% macro binary_broadcast_offsets() %}
79
+ {% set aShape = aShape | default([]) %}
80
+ {% set aRank = aRank | default(0) %}
81
+ {% set bShape = bShape | default([]) %}
82
+ {% set bRank = bRank | default(0) %}
83
+ {% set cShape = cShape | default([]) %}
84
+ {% set cRank = cRank | default(0) %}
85
+ {{ broadcast_offset_fn("a_offset", aShape, aRank, cShape, cRank) }}
86
 
87
+ {{ broadcast_offset_fn("b_offset", bShape, bRank, cShape, cRank) }}
88
  {%- endmacro %}
89
 
 
 
 
90
  {{ env.wgsl.resourceDeclarations }}
91
 
92
 
93
  {{ binary_broadcast_offsets() }}
94
 
95
  {{ flat_tail_open() }}
96
+ c[i] = select(0u, 1u, a[{{ broadcast_offset_call("a_offset", aShape, cShape, "i") }}] < b[{{ broadcast_offset_call("b_offset", bShape, cShape, "i") }}]);
97
  {{ flat_tail_close() -}}
98
  }
build/webgpu/compare-vec4.wgsl.jinja CHANGED
@@ -1,17 +1,46 @@
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
  }
 
 
 
 
1
  {{ env.wgsl.resourceDeclarations }}
2
 
3
+ {% set vec4PerThread = vec4PerThread %}
4
+ {% if vec4PerThread > 1 %}
5
+ const ITEMS: u32 = {{ vec4PerThread }}u;
6
+ {% endif %}
7
+
8
  @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
9
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
10
  // 2D-folded flat index: gid.y carries the high bits when the element count exceeds the
11
+ // per-axis dispatch fold width (the dispatch caps x and spills the rest into y).
12
+ {% if vec4PerThread > 1 %}
13
+ // Each invocation walks ITEMS vec4 groups a span apart. Consecutive lanes
14
+ // access consecutive words on every step, while each lane can keep several
15
+ // independent loads in flight.
16
+ let tid = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ tunables.WORKGROUP_SIZE }}u;
17
+ let span = (params.count + ITEMS - 1u) / ITEMS;
18
+ for (var j = 0u; j < ITEMS; j = j + 1u) {
19
+ let i = tid + j * span;
20
+ if (i >= params.count) {
21
+ break;
22
+ }
23
+ {% else %}
24
+ let i = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ tunables.WORKGROUP_SIZE }}u;
25
  if (i >= params.count) {
26
  return;
27
  }
28
+ {% endif %}
29
+
30
+ {% set scalarOperand = scalarOperand if scalarOperand is defined else "" %}
31
+ {% if scalarOperand == "a" %}
32
+ // One-element operand: read once and splat across the vector.
33
+ let av = {{ vectorScalar }}(a[0]);
34
+ {% else %}
35
  let av = a[i];
36
+ {% endif %}
37
+ {% if scalarOperand == "b" %}
38
+ let bv = {{ vectorScalar }}(b[0]);
39
+ {% else %}
40
  let bv = b[i];
41
+ {% endif %}
42
  c[i] = select(vec4<u32>(0u), vec4<u32>(1u), av < bv);
43
+ {% if vec4PerThread > 1 %}
44
+ }
45
+ {% endif %}
46
  }
build/webgpu/manifest.json CHANGED
@@ -2,215 +2,182 @@
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
- "itemsPerInvocation": 4
137
- }
138
  },
139
- "bindings": [
140
- {
141
- "name": "a",
142
- "arg": "a",
143
- "semantic": "A",
144
- "buffer": { "type": "read-only-storage" },
145
- "elementType": "$scalar"
146
- },
147
- {
148
- "name": "b",
149
- "arg": "b",
150
- "semantic": "B",
151
- "buffer": { "type": "read-only-storage" },
152
- "elementType": "$scalar"
153
- },
154
- { "name": "c", "arg": "c", "semantic": "C", "buffer": { "type": "storage" }, "elementType": "u32" },
155
- {
156
- "name": "params",
157
- "semantic": "kernel.params",
158
- "buffer": { "type": "uniform" },
159
- "struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.C)" }] }
160
- }
161
- ],
162
- "dispatch": { "threads": "ceilDiv(numel(shapes.C), 4)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
163
  }
164
  ]
165
  },
166
  {
167
  "id": "same_shape_scalar_x4",
168
  "priority": 15,
169
- "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)"],
170
- "constants": { "scalar": "dtypes.T", "usesF16": "dtypes.T == \"f16\"" },
171
  "passes": [
172
  {
173
  "id": "main",
174
  "name": "Less",
175
- "source": {
176
- "shader": "compare-broadcast.wgsl.jinja",
177
- "inputs": {
178
- "aShape": "shapes.A",
179
- "bShape": "shapes.B",
180
- "cShape": "shapes.C",
181
- "aRank": "ranks.A",
182
- "bRank": "ranks.B",
183
- "cRank": "ranks.C",
184
- "op": "\"less\"",
185
- "itemsPerInvocation": 4
186
- }
187
  },
188
- "bindings": [
189
- {
190
- "name": "a",
191
- "arg": "a",
192
- "semantic": "A",
193
- "buffer": { "type": "read-only-storage" },
194
- "elementType": "$scalar"
195
- },
196
- {
197
- "name": "b",
198
- "arg": "b",
199
- "semantic": "B",
200
- "buffer": { "type": "read-only-storage" },
201
- "elementType": "$scalar"
202
- },
203
- { "name": "c", "arg": "c", "semantic": "C", "buffer": { "type": "storage" }, "elementType": "u32" },
204
- {
205
- "name": "params",
206
- "semantic": "kernel.params",
207
- "buffer": { "type": "uniform" },
208
- "struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.C)" }] }
209
- }
210
- ],
211
- "dispatch": { "threads": "ceilDiv(numel(shapes.C), 4)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
212
  }
213
  ]
214
  }
215
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  }
 
2
  "domain": "ai.onnx",
3
  "name": "Less",
4
  "sinceVersion": 13,
5
+ "inputs": { "a": { "onnx": "A", "dtype": "T" }, "b": { "onnx": "B", "dtype": "T" } },
6
+ "outputs": {
7
+ "c": { "onnx": "C", "dtype": "B", "rank": "max(ranks.a, ranks.b)", "shape": "broadcastShape(shapes.a, shapes.b)" }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  },
9
+ "typeConstraints": { "T": ["float32", "float16", "int32", "int16", "uint32", "int8", "uint8"], "B": ["bool"] },
10
+ "tunables": { "WORKGROUP_SIZE": { "default": 256 } },
11
  "variants": [
12
  {
13
  "id": "same_shape_vec4",
14
  "priority": 20,
15
+ "when": ["sameShape(shapes.a, shapes.c)", "sameShape(shapes.b, shapes.c)", "numel(shapes.c) > 0", "numel(shapes.c) % 4 == 0", "f16Ok(dtypes.T)"],
16
+ "derive": { "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" },
17
  "passes": [
18
  {
19
  "id": "main",
20
  "name": "Less.vec4",
21
+ "shader": "compare-vec4.wgsl.jinja",
22
+ "derive": {
23
+ "op": "\"less\"",
24
+ "vec4PerThread": "4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"
25
+ },
26
+ "bindings": ["a", "b", "c", "params"],
27
+ "dispatch": {
28
+ "x": "min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
29
+ "y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
30
+ "z": 1
31
+ }
32
+ }
33
+ ]
34
+ },
35
+ {
36
+ "id": "scalar_b_vec4",
37
+ "priority": 18,
38
+ "when": ["sameShape(shapes.a, shapes.c)", "numel(shapes.b) == 1", "numel(shapes.c) > 0", "numel(shapes.c) % 4 == 0", "f16Ok(dtypes.T)"],
39
+ "derive": { "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"", "scalar": "dtypes.T" },
40
+ "passes": [
41
+ {
42
+ "id": "main",
43
+ "name": "Less.scalarBVec4",
44
+ "shader": "compare-vec4.wgsl.jinja",
45
+ "derive": {
46
+ "op": "\"less\"",
47
+ "scalarOperand": "\"b\"",
48
+ "vec4PerThread": "4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"
49
+ },
50
+ "bindings": ["a", "b_2", "c", "params"],
51
+ "dispatch": {
52
+ "x": "min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
53
+ "y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
54
+ "z": 1
55
+ }
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ "id": "scalar_a_vec4",
61
+ "priority": 18,
62
+ "when": ["sameShape(shapes.b, shapes.c)", "numel(shapes.a) == 1", "numel(shapes.c) > 0", "numel(shapes.c) % 4 == 0", "f16Ok(dtypes.T)"],
63
+ "derive": { "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"", "scalar": "dtypes.T" },
64
+ "passes": [
65
+ {
66
+ "id": "main",
67
+ "name": "Less.scalarAVec4",
68
+ "shader": "compare-vec4.wgsl.jinja",
69
+ "derive": {
70
+ "op": "\"less\"",
71
+ "scalarOperand": "\"a\"",
72
+ "vec4PerThread": "4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"
73
+ },
74
+ "bindings": ["a_2", "b", "c", "params"],
75
+ "dispatch": {
76
+ "x": "min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
77
+ "y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
78
+ "z": 1
79
+ }
80
  }
81
  ]
82
  },
83
  {
84
  "id": "broadcast_vec4",
85
+ "priority": 10,
86
+ "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)"],
87
+ "derive": { "scalar": "dtypes.T" },
88
  "passes": [
89
  {
90
  "id": "main",
91
  "name": "Less",
92
+ "shader": "compare-broadcast-vec4.wgsl.jinja",
93
+ "derive": {
94
+ "aShape": "shapes.a",
95
+ "bShape": "shapes.b",
96
+ "cShape": "shapes.c",
97
+ "aRank": "ranks.a",
98
+ "bRank": "ranks.b",
99
+ "cRank": "ranks.c",
100
+ "op": "\"less\""
 
 
101
  },
102
+ "bindings": ["a_2", "b_2", "c", "params"],
103
+ "dispatch": {
104
+ "x": "min(ceilDiv((numel(shapes.c) / 4), (tunables.WORKGROUP_SIZE)), min(device.limits.maxComputeWorkgroupsPerDimension, 65535))",
105
+ "y": 1,
106
+ "z": 1
107
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
+ ]
 
110
  },
111
  {
112
  "id": "broadcast",
113
+ "when": ["ranks.a <= ranks.c", "ranks.b <= ranks.c", "f16Ok(dtypes.T)"],
114
+ "derive": { "scalar": "dtypes.T" },
115
  "passes": [
116
  {
117
  "id": "main",
118
  "name": "Less",
119
+ "shader": "compare-broadcast.wgsl.jinja",
120
+ "derive": {
121
+ "aShape": "shapes.a",
122
+ "bShape": "shapes.b",
123
+ "cShape": "shapes.c",
124
+ "aRank": "ranks.a",
125
+ "bRank": "ranks.b",
126
+ "cRank": "ranks.c",
127
+ "op": "\"less\"",
128
+ "itemsPerInvocation": 4
 
 
129
  },
130
+ "bindings": ["a_2", "b_2", "c_2", "params_2"],
131
+ "dispatch": {
132
+ "x": "min(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
133
+ "y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
134
+ "z": 1
135
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
  ]
138
  },
139
  {
140
  "id": "same_shape_scalar_x4",
141
  "priority": 15,
142
+ "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)"],
143
+ "derive": { "scalar": "dtypes.T" },
144
  "passes": [
145
  {
146
  "id": "main",
147
  "name": "Less",
148
+ "shader": "compare-broadcast.wgsl.jinja",
149
+ "derive": {
150
+ "aShape": "shapes.a",
151
+ "bShape": "shapes.b",
152
+ "cShape": "shapes.c",
153
+ "aRank": "ranks.a",
154
+ "bRank": "ranks.b",
155
+ "cRank": "ranks.c",
156
+ "op": "\"less\"",
157
+ "itemsPerInvocation": 4
 
 
158
  },
159
+ "bindings": ["a_2", "b_2", "c_2", "params_2"],
160
+ "dispatch": {
161
+ "x": "min(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
162
+ "y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
163
+ "z": 1
164
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
  ]
167
  }
168
+ ],
169
+ "bindings": {
170
+ "a": { "buffer": "read-only-storage", "elementType": "$vectorScalar" },
171
+ "b": { "buffer": "read-only-storage", "elementType": "$vectorScalar" },
172
+ "c": { "buffer": "storage", "elementType": "vec4<u32>" },
173
+ "params": { "buffer": "uniform", "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.c) / 4" }] },
174
+ "b_2": { "buffer": "read-only-storage", "name": "b", "elementType": "$scalar" },
175
+ "a_2": { "buffer": "read-only-storage", "name": "a", "elementType": "$scalar" },
176
+ "c_2": { "buffer": "storage", "name": "c", "elementType": "u32" },
177
+ "params_2": {
178
+ "buffer": "uniform",
179
+ "name": "params",
180
+ "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.c)" }]
181
+ }
182
+ }
183
  }
build/webgpu/metadata.json CHANGED
@@ -1,20 +1,30 @@
1
  {
2
  "name": "ai.onnx.Less",
3
- "id": "_ai_onnx_less_webgpu_622f298",
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": "8JaFKuwhZhkyz/5Z52Y12lDykGVTeSupcVNarIVl/3k=",
13
- "compare-vec4.wgsl.jinja": "cXSOC920mmdSmQNgxaMiUZDh4jmFywSvCjPxMr8SAjI=",
14
- "manifest.json": "wAE9MngLrMCvMj2SOAHfFV2Z06CFHidS/BltK6nFkr4=",
15
- "test.json": "1ZrEwckIRspwkQp9fLSrgGzAcBEUXKJKNXIU81H+DYE="
16
  }
17
  },
18
- "provenance": { "kernel": { "sha": "c928d21e6cc1310861cba3bafb75f5f679ecf5f3", "dirty": false } },
19
- "webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/ai.onnx.Less" }
 
 
 
 
 
 
 
 
 
 
20
  }
 
1
  {
2
  "name": "ai.onnx.Less",
3
+ "id": "_ai_onnx_less_webgpu_cd5aeae",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "backend": { "type": "webgpu" },
7
  "digest": {
8
  "algorithm": "sha256",
9
  "files": {
10
+ "bench.json": "DYOpGhl+2huEW8ES9/klafDCuls+BKZycGYBsG3xuXc=",
11
+ "compare-broadcast-vec4.wgsl.jinja": "e9IjvIN8zaZuy3Oxyo0917Z43virxHPxIKYg4GD5DDo=",
12
+ "compare-broadcast.wgsl.jinja": "149Y9wl0draPoa3sCNPbGVSvEk3Z4G0Rt1lifzBbCFM=",
13
+ "compare-vec4.wgsl.jinja": "HHor4TZ32hagFcdLFOoBRtFnH6CyrYjaIcviPAUhSWM=",
14
+ "manifest.json": "IhvdJxWOC3OjvHtb6mjf/7GCfUAHPm1gIjVpfWwLKNk=",
15
+ "test.json": "BkFQK6dgyaPaA0W1QSVZO1MlUw5afjqO9YwzV1lymrg="
16
  }
17
  },
18
+ "provenance": { "kernel": { "sha": "91d990483a174128daf7673f3f37a7c890493ae1", "dirty": false } },
19
+ "webgpu": {
20
+ "manifestSpec": "2.0",
21
+ "variants": {
22
+ "same_shape_vec4": ["compare-vec4.wgsl.jinja"],
23
+ "scalar_b_vec4": ["compare-vec4.wgsl.jinja"],
24
+ "scalar_a_vec4": ["compare-vec4.wgsl.jinja"],
25
+ "broadcast_vec4": ["compare-broadcast-vec4.wgsl.jinja"],
26
+ "broadcast": ["compare-broadcast.wgsl.jinja"],
27
+ "same_shape_scalar_x4": ["compare-broadcast.wgsl.jinja"]
28
+ }
29
+ }
30
  }
build/webgpu/test.json CHANGED
@@ -1,8 +1,8 @@
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
  {
@@ -31,7 +31,7 @@
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] } },
@@ -167,11 +167,7 @@
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
  },
@@ -435,18 +431,18 @@
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 } }
@@ -478,9 +474,9 @@
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] } },
@@ -498,7 +494,7 @@
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
  },
@@ -518,9 +514,9 @@
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] } },
@@ -531,6 +527,36 @@
531
  }
532
  },
533
  "outputs": { "c": { "dtype": "bool", "shape": [2, 4], "tolerance": 0 } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  }
535
  ]
536
  }
 
1
  {
 
2
  "fixtureArrays": {
3
  "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],
4
+ "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],
5
+ "scalarOperandRouteValues": [0.5, -1, 2, 0.25, 3, -2, 0.25, 1, 0.75, 0.25, -0.5, 4, 0.125, 0.25, -3, 2.5]
6
  },
7
  "cases": [
8
  {
 
31
  "provenance": {
32
  "source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
33
  "test": "MathOpTest.Less",
34
+ "notes": "On an unaligned scalar path, negative subnormals are strictly less than zero and must produce true mask lanes."
35
  },
36
  "inputs": {
37
  "a": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [-1e-40, 0.0, 1e-40] } },
 
167
  "shape": [4],
168
  "data": { "kind": "values", "values": ["NaN", 1.0, "Infinity", "-Infinity"] }
169
  },
170
+ "b": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.0, "NaN", "Infinity", 0.0] } }
 
 
 
 
171
  },
172
  "outputs": { "c": { "dtype": "bool", "shape": [4], "tolerance": 0 } }
173
  },
 
431
  {
432
  "name": "f32_broadcast_odd_inner_dim_4x17",
433
  "provenance": {
434
+ "notes": "A compact float32 [rows, odd] by [odd] broadcast exercises an odd inner dimension without benchmark-scale rows."
435
  },
436
  "inputs": {
437
  "a": {
438
  "dtype": "float32",
439
  "shape": [4, 17],
440
+ "data": { "kind": "fillFloat32", "sinStep": 0.23, "cosStep": 0.53, "scale": 0.5 }
441
  },
442
  "b": {
443
  "dtype": "float32",
444
  "shape": [17],
445
+ "data": { "kind": "fillFloat32", "sinStep": 0.41, "cosStep": 0.71, "scale": 0.5 }
446
  }
447
  },
448
  "outputs": { "c": { "dtype": "bool", "shape": [4, 17], "tolerance": 0 } }
 
474
  {
475
  "name": "broadcast_vec4_lhs_splat_lower_rank",
476
  "provenance": {
477
+ "source": "constructed fixture",
478
  "test": "compare-broadcast-vec4 lhs splat arm",
479
+ "notes": "A has rank 2 against a rank-3 output and an innermost dimension of 1, so each A row is splatted across one output row. Distinct values in every A row and B position make an incorrect broadcast offset observable."
480
  },
481
  "inputs": {
482
  "a": { "dtype": "float32", "shape": [3, 1], "data": { "kind": "values", "values": [10.0, 20.0, 30.0] } },
 
494
  {
495
  "name": "broadcast_vec4_rhs_splat_lower_rank",
496
  "provenance": {
497
+ "source": "constructed fixture",
498
  "test": "compare-broadcast-vec4 rhs splat arm",
499
  "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."
500
  },
 
514
  {
515
  "name": "broadcast_vec4_true_scalar_lhs",
516
  "provenance": {
517
+ "source": "constructed fixture",
518
  "test": "compare-broadcast-vec4 rank-0 lhs arm",
519
+ "notes": "A is a rank-0 scalar that broadcasts to every output position. An innermost dimension of four and eight total outputs exercise vectorized comparison, while distinct B values make scalar-A indexing observable."
520
  },
521
  "inputs": {
522
  "a": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [20.0] } },
 
527
  }
528
  },
529
  "outputs": { "c": { "dtype": "bool", "shape": [2, 4], "tolerance": 0 } }
530
+ },
531
+ {
532
+ "name": "scalar_b_vec4_route",
533
+ "provenance": {
534
+ "notes": "Route lock for the one-element-operand vec4 kernel: the other operand matches the output and the vector count is a multiple of four, so the scalar reads once and splats. Values straddle and hit the scalar exactly, so the compare emits both results."
535
+ },
536
+ "inputs": {
537
+ "a": {
538
+ "dtype": "float32",
539
+ "shape": [2, 8],
540
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/scalarOperandRouteValues" } }
541
+ },
542
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.25] } }
543
+ },
544
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 8], "tolerance": 0 } }
545
+ },
546
+ {
547
+ "name": "scalar_a_vec4_route",
548
+ "provenance": {
549
+ "notes": "Route lock for the one-element-operand vec4 kernel: the other operand matches the output and the vector count is a multiple of four, so the scalar reads once and splats. Values straddle and hit the scalar exactly, so the compare emits both results."
550
+ },
551
+ "inputs": {
552
+ "a": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.25] } },
553
+ "b": {
554
+ "dtype": "float32",
555
+ "shape": [2, 8],
556
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/scalarOperandRouteValues" } }
557
+ }
558
+ },
559
+ "outputs": { "c": { "dtype": "bool", "shape": [2, 8], "tolerance": 0 } }
560
  }
561
  ]
562
  }