sync 4385228f788d
Browse files- README.md +15 -10
- build/webgpu/bench.json +99 -0
- build/webgpu/binary-broadcast-vec4.wgsl.jinja +73 -55
- build/webgpu/binary-broadcast.wgsl.jinja +2 -2
- build/webgpu/binary-vec4.wgsl.jinja +37 -38
- build/webgpu/manifest.json +1 -163
- build/webgpu/metadata.json +1 -29
- build/webgpu/test.json +231 -2
README.md
CHANGED
|
@@ -37,30 +37,35 @@ See the [ONNX `Div` spec](https://onnx.ai/onnx/operators/onnx__Div.html) for the
|
|
| 37 |
|
| 38 |
## Files
|
| 39 |
|
| 40 |
-
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests,
|
| 41 |
-
- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
|
| 42 |
-
- [`test.json`](build/webgpu/test.json) — correctness cases
|
| 43 |
-
- [`bench.json`](build/webgpu/bench.json) — benchmark cases
|
| 44 |
-
- [`binary-broadcast-vec4.wgsl.jinja`](build/webgpu/binary-broadcast-vec4.wgsl.jinja)
|
| 45 |
-
- [`binary-broadcast.wgsl.jinja`](build/webgpu/binary-broadcast.wgsl.jinja)
|
| 46 |
-
- [`binary-vec4.wgsl.jinja`](build/webgpu/binary-vec4.wgsl.jinja)
|
| 47 |
|
| 48 |
## Use with `@huggingface/kernels`
|
| 49 |
|
| 50 |
```sh
|
| 51 |
-
npm install --save-exact @huggingface/kernels@0.0.1-preview.
|
| 52 |
```
|
| 53 |
|
|
|
|
|
|
|
| 54 |
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
|
| 55 |
|
| 56 |
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 57 |
It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
|
| 58 |
|
| 59 |
-
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
|
| 60 |
-
|
| 61 |
```js
|
| 62 |
import { getKernel } from "@huggingface/kernels";
|
| 63 |
|
| 64 |
const kernel = await getKernel("webgpu-kernels/ai.onnx.Div", { version: 1 });
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
const { c } = await kernel({ a: { data: aData, shape: [1] }, b: { data: bData, shape: [1] } });
|
|
|
|
| 66 |
```
|
|
|
|
| 37 |
|
| 38 |
## Files
|
| 39 |
|
| 40 |
+
- [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.Div/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)
|
| 41 |
+
- [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.Div/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)
|
| 42 |
+
- [`test.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.Div/blob/v1/build/webgpu/test.json) — correctness cases
|
| 43 |
+
- [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.Div/blob/v1/build/webgpu/bench.json) — benchmark cases
|
| 44 |
+
- [`binary-broadcast-vec4.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.Div/blob/v1/build/webgpu/binary-broadcast-vec4.wgsl.jinja)
|
| 45 |
+
- [`binary-broadcast.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.Div/blob/v1/build/webgpu/binary-broadcast.wgsl.jinja)
|
| 46 |
+
- [`binary-vec4.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.Div/blob/v1/build/webgpu/binary-vec4.wgsl.jinja)
|
| 47 |
|
| 48 |
## Use with `@huggingface/kernels`
|
| 49 |
|
| 50 |
```sh
|
| 51 |
+
npm install --save-exact @huggingface/kernels@0.0.1-preview.4
|
| 52 |
```
|
| 53 |
|
| 54 |
+
Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.
|
| 55 |
+
|
| 56 |
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
|
| 57 |
|
| 58 |
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 59 |
It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
|
| 60 |
|
|
|
|
|
|
|
| 61 |
```js
|
| 62 |
import { getKernel } from "@huggingface/kernels";
|
| 63 |
|
| 64 |
const kernel = await getKernel("webgpu-kernels/ai.onnx.Div", { version: 1 });
|
| 65 |
+
|
| 66 |
+
const aData = Float32Array.of(58720216);
|
| 67 |
+
const bData = Float32Array.of(7);
|
| 68 |
+
|
| 69 |
const { c } = await kernel({ a: { data: aData, shape: [1] }, b: { data: bData, shape: [1] } });
|
| 70 |
+
console.log({ c });
|
| 71 |
```
|
build/webgpu/bench.json
CHANGED
|
@@ -67,6 +67,105 @@
|
|
| 67 |
},
|
| 68 |
"outputs": { "c": { "shape": [4096, 1023], "dtype": "float32", "dist": "empty" } },
|
| 69 |
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
}
|
| 71 |
]
|
| 72 |
}
|
|
|
|
| 67 |
},
|
| 68 |
"outputs": { "c": { "shape": [4096, 1023], "dtype": "float32", "dist": "empty" } },
|
| 69 |
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"name": "broadcast-float32-rhs-p5",
|
| 73 |
+
"preset": "stress",
|
| 74 |
+
"vars": { "dtype": "float32", "count": 163840 },
|
| 75 |
+
"inputs": {
|
| 76 |
+
"a": { "dtype": "float32", "shape": [32768, 5], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 77 |
+
"b": { "dtype": "float32", "shape": [5], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 78 |
+
},
|
| 79 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 5] } },
|
| 80 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"name": "broadcast-float32-rhs-p6",
|
| 84 |
+
"preset": "stress",
|
| 85 |
+
"vars": { "dtype": "float32", "count": 196608 },
|
| 86 |
+
"inputs": {
|
| 87 |
+
"a": { "dtype": "float32", "shape": [32768, 6], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 88 |
+
"b": { "dtype": "float32", "shape": [6], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 89 |
+
},
|
| 90 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 6] } },
|
| 91 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"name": "broadcast-float32-rhs-p8",
|
| 95 |
+
"preset": "stress",
|
| 96 |
+
"vars": { "dtype": "float32", "count": 262144 },
|
| 97 |
+
"inputs": {
|
| 98 |
+
"a": { "dtype": "float32", "shape": [32768, 8], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 99 |
+
"b": { "dtype": "float32", "shape": [8], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 100 |
+
},
|
| 101 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 8] } },
|
| 102 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"name": "broadcast-float32-lhs-p13",
|
| 106 |
+
"preset": "stress",
|
| 107 |
+
"vars": { "dtype": "float32", "count": 425984 },
|
| 108 |
+
"inputs": {
|
| 109 |
+
"a": { "dtype": "float32", "shape": [13], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 110 |
+
"b": { "dtype": "float32", "shape": [32768, 13], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 111 |
+
},
|
| 112 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 13] } },
|
| 113 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"name": "broadcast-float16-rhs-p13",
|
| 117 |
+
"preset": "stress",
|
| 118 |
+
"vars": { "dtype": "float16", "count": 425984 },
|
| 119 |
+
"inputs": {
|
| 120 |
+
"a": { "dtype": "float16", "shape": [32768, 13], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 121 |
+
"b": { "dtype": "float16", "shape": [13], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 122 |
+
},
|
| 123 |
+
"outputs": { "c": { "dtype": "float16", "shape": [32768, 13] } },
|
| 124 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"name": "broadcast-float32-rhs-p20",
|
| 128 |
+
"preset": "stress",
|
| 129 |
+
"vars": { "dtype": "float32", "count": 655360 },
|
| 130 |
+
"inputs": {
|
| 131 |
+
"a": { "dtype": "float32", "shape": [32768, 4, 5], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 132 |
+
"b": { "dtype": "float32", "shape": [4, 5], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 133 |
+
},
|
| 134 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 4, 5] } },
|
| 135 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"name": "broadcast-float32-rhs-p63",
|
| 139 |
+
"preset": "stress",
|
| 140 |
+
"vars": { "dtype": "float32", "count": 2064384 },
|
| 141 |
+
"inputs": {
|
| 142 |
+
"a": { "dtype": "float32", "shape": [32768, 63], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 143 |
+
"b": { "dtype": "float32", "shape": [63], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 144 |
+
},
|
| 145 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 63] } },
|
| 146 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"name": "broadcast-float32-rhs-p65",
|
| 150 |
+
"preset": "stress",
|
| 151 |
+
"vars": { "dtype": "float32", "count": 2129920 },
|
| 152 |
+
"inputs": {
|
| 153 |
+
"a": { "dtype": "float32", "shape": [32768, 65], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 154 |
+
"b": { "dtype": "float32", "shape": [65], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 155 |
+
},
|
| 156 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 65] } },
|
| 157 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"name": "broadcast-float32-rhs-p255",
|
| 161 |
+
"preset": "stress",
|
| 162 |
+
"vars": { "dtype": "float32", "count": 8355840 },
|
| 163 |
+
"inputs": {
|
| 164 |
+
"a": { "dtype": "float32", "shape": [32768, 255], "dist": "normal", "seed": 441, "offset": 4, "scale": 0.5 },
|
| 165 |
+
"b": { "dtype": "float32", "shape": [255], "dist": "normal", "seed": 442, "offset": 1, "scale": 0.1 }
|
| 166 |
+
},
|
| 167 |
+
"outputs": { "c": { "dtype": "float32", "shape": [32768, 255] } },
|
| 168 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "args.count * dtypeBytes(args.dtype) * 2" }] }
|
| 169 |
}
|
| 170 |
]
|
| 171 |
}
|
build/webgpu/binary-broadcast-vec4.wgsl.jinja
CHANGED
|
@@ -44,30 +44,69 @@ fn {{ fn_name }}({% if out_numel != 0 and op_numel != 1 %}out_index: u32{% endif
|
|
| 44 |
{% set out_numel.value = out_numel.value * d %}
|
| 45 |
{% endfor %}
|
| 46 |
{{ fn_name }}({% if out_numel.value != 0 and op_numel.value != 1 %}{{ out_index }}{% endif %}){% endmacro %}
|
| 47 |
-
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count"
|
| 48 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 49 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 50 |
// per-axis workgroup fold width.
|
| 51 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 52 |
if ({{ name }} >= {{ bound }}) {
|
| 53 |
return;
|
| 54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
{{ env.wgsl.resourceDeclarations }}
|
| 56 |
|
| 57 |
-
// Vec4 broadcast binary op. Offsets use compile-time strides, and each
|
| 58 |
-
// invocation writes four output values. If the output's innermost axis is a
|
| 59 |
-
// multiple of four, each operand uses one base offset. For an
|
| 60 |
-
// odd innermost extent, a vec4 may cross a row boundary: same-shape operands
|
| 61 |
-
// remain contiguous, while broadcast operands compute the four lane offsets
|
| 62 |
-
// independently so their outer broadcast coordinates wrap correctly. Under
|
| 63 |
-
// broadcasting each operand axis is either matched (== output) or 1, so the
|
| 64 |
-
// innermost axis of each operand is exactly one of:
|
| 65 |
-
// - "scalar" : the whole operand is one element -> splat a[0]
|
| 66 |
-
// - "splat" : innermost axis is 1 (broadcast) -> splat a[offset(base)]
|
| 67 |
-
// - "contiguous" : innermost axis matches the output -> vec4 a[offset(base)..+3]
|
| 68 |
-
// Outer-axis broadcasting is captured by offset(base). A fully same-shape
|
| 69 |
-
// operand is vector-bound and loaded directly; broadcast operands remain
|
| 70 |
-
// scalar-bound so their independent lane offsets stay addressable.
|
| 71 |
{% set a_numel = namespace(value=1) %}
|
| 72 |
{% for d in aShape %}
|
| 73 |
{% set a_numel.value = a_numel.value * d %}
|
|
@@ -107,11 +146,15 @@ fn {{ fn_name }}({% if out_numel != 0 and op_numel != 1 %}out_index: u32{% endif
|
|
| 107 |
{% elif b_inner == 1 %}{% set b_mode = "splat" %}
|
| 108 |
{% else %}{% set b_mode = "contig" %}{% endif %}
|
| 109 |
|
| 110 |
-
{%
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
{{ offset_fn("a_offset", aShape, aRank, false, a_numel.value, cShape, cRank, c_numel.value) }}
|
| 112 |
|
| 113 |
{% endif %}
|
| 114 |
-
{% if not b_same.value and b_mode != "scalar" %}
|
| 115 |
{{ offset_fn("b_offset", bShape, bRank, false, b_numel.value, cShape, cRank, c_numel.value) }}
|
| 116 |
|
| 117 |
{% endif %}
|
|
@@ -128,53 +171,28 @@ fn wrap_dtype(v: vec4<u32>) -> vec4<u32> { return v & vec4<u32>(0xFFu); }
|
|
| 128 |
{% else %}
|
| 129 |
{% set wrap = "" %}
|
| 130 |
{% endif %}
|
|
|
|
|
|
|
| 131 |
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
|
| 132 |
-
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
{{ flat_index_2d(tunables.WORKGROUP_SIZE, "i4") }}
|
| 134 |
-
{% set needsBase = c_numel.value != 0 and ((not a_same.value and a_mode != "scalar") or (not b_same.value and b_mode != "scalar")) %}
|
| 135 |
{% if needsBase %}
|
| 136 |
let base = i4 * 4u;
|
| 137 |
{% endif %}
|
| 138 |
-
{
|
| 139 |
-
|
| 140 |
-
{% elif a_mode == "scalar" %}
|
| 141 |
-
let av = vec4<{{ acc }}>({{ acc }}(a[0]));
|
| 142 |
-
{% elif crosses_inner_rows %}
|
| 143 |
-
let av = vec4<{{ acc }}>(
|
| 144 |
-
{{ acc }}(a[{{ broadcast_offset_call("a_offset", aShape, cShape, "base") }}]),
|
| 145 |
-
{{ acc }}(a[{{ broadcast_offset_call("a_offset", aShape, cShape, "base + 1u") }}]),
|
| 146 |
-
{{ acc }}(a[{{ broadcast_offset_call("a_offset", aShape, cShape, "base + 2u") }}]),
|
| 147 |
-
{{ acc }}(a[{{ broadcast_offset_call("a_offset", aShape, cShape, "base + 3u") }}])
|
| 148 |
-
);
|
| 149 |
-
{% elif a_mode == "splat" %}
|
| 150 |
-
let av = vec4<{{ acc }}>({{ acc }}(a[{{ broadcast_offset_call("a_offset", aShape, cShape, "base") }}]));
|
| 151 |
-
{% else %}
|
| 152 |
-
let ao = {{ broadcast_offset_call("a_offset", aShape, cShape, "base") }};
|
| 153 |
-
let av = vec4<{{ acc }}>({{ acc }}(a[ao]), {{ acc }}(a[ao + 1u]), {{ acc }}(a[ao + 2u]), {{ acc }}(a[ao + 3u]));
|
| 154 |
-
{% endif %}
|
| 155 |
-
{% if b_same.value %}
|
| 156 |
-
let bv = vec4<{{ acc }}>(b[i4]);
|
| 157 |
-
{% elif b_mode == "scalar" %}
|
| 158 |
-
let bv = vec4<{{ acc }}>({{ acc }}(b[0]));
|
| 159 |
-
{% elif crosses_inner_rows %}
|
| 160 |
-
let bv = vec4<{{ acc }}>(
|
| 161 |
-
{{ acc }}(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "base") }}]),
|
| 162 |
-
{{ acc }}(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "base + 1u") }}]),
|
| 163 |
-
{{ acc }}(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "base + 2u") }}]),
|
| 164 |
-
{{ acc }}(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "base + 3u") }}])
|
| 165 |
-
);
|
| 166 |
-
{% elif b_mode == "splat" %}
|
| 167 |
-
let bv = vec4<{{ acc }}>({{ acc }}(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "base") }}]));
|
| 168 |
-
{% else %}
|
| 169 |
-
let bo = {{ broadcast_offset_call("b_offset", bShape, cShape, "base") }};
|
| 170 |
-
let bv = vec4<{{ acc }}>({{ acc }}(b[bo]), {{ acc }}(b[bo + 1u]), {{ acc }}(b[bo + 2u]), {{ acc }}(b[bo + 3u]));
|
| 171 |
-
{% endif %}
|
| 172 |
{% if is_int %}
|
| 173 |
c[i4] = {{ wrap }}(vec4<{{ scalar }}>(av / bv));
|
| 174 |
{% else %}
|
| 175 |
let quotient = av / bv;
|
| 176 |
let rounded = round(quotient);
|
| 177 |
-
// Component-wise Div snap guard:
|
| 178 |
// integer quotient, while half-integers must stay untouched.
|
| 179 |
let snapProduct = rounded * bv == av;
|
| 180 |
let snapClose = abs(quotient - rounded) < vec4<f32>(0.5);
|
|
|
|
| 44 |
{% set out_numel.value = out_numel.value * d %}
|
| 45 |
{% endfor %}
|
| 46 |
{{ fn_name }}({% if out_numel.value != 0 and op_numel.value != 1 %}{{ out_index }}{% endif %}){% endmacro %}
|
| 47 |
+
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count") %}
|
| 48 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 49 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 50 |
// per-axis workgroup fold width.
|
| 51 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 52 |
if ({{ name }} >= {{ bound }}) {
|
| 53 |
return;
|
| 54 |
+
}
|
| 55 |
+
{% endmacro %}
|
| 56 |
+
{% macro periodic_geometry(g, shape, rank, same, count, outputShape, outputRank, crosses, capacity) -%}
|
| 57 |
+
{%- for axis in range(outputRank) | reverse -%}
|
| 58 |
+
{%- set operandAxis = axis - (outputRank - rank) -%}
|
| 59 |
+
{%- if g.matching and operandAxis >= 0 and shape[operandAxis] == outputShape[axis] -%}
|
| 60 |
+
{%- set g.period = g.period * outputShape[axis] -%}
|
| 61 |
+
{%- else -%}
|
| 62 |
+
{%- set g.matching = false -%}
|
| 63 |
+
{%- endif -%}
|
| 64 |
+
{%- endfor -%}
|
| 65 |
+
{%- set g.active = not same and crosses and g.period >= 4 and g.period == count and g.period <= capacity -%}
|
| 66 |
+
{%- endmacro %}
|
| 67 |
+
{% macro periodic_declaration(name, g, acc) -%}
|
| 68 |
+
{% if g.active %}
|
| 69 |
+
var<workgroup> table_{{ name }}: array<vec4<{{ acc }}>, {{ g.period }}>;
|
| 70 |
+
{% endif %}
|
| 71 |
+
{%- endmacro %}
|
| 72 |
+
{% macro periodic_stage(name, g, acc) -%}
|
| 73 |
+
{% if g.active %}
|
| 74 |
+
if (lid < {{ g.period }}u) {
|
| 75 |
+
let base_{{ name }} = (lid * 4u) % {{ g.period }}u;
|
| 76 |
+
table_{{ name }}[lid] = vec4<{{ acc }}>(
|
| 77 |
+
{% for lane in range(4) %}
|
| 78 |
+
{{ acc }}({{ name }}[{% if lane == 0 %}base_{{ name }}{% else %}(base_{{ name }} + {{ lane }}u) % {{ g.period }}u{% endif %}]){{ "," if lane < 3 else "" }}
|
| 79 |
+
{% endfor %}
|
| 80 |
+
);
|
| 81 |
+
}
|
| 82 |
+
{% endif %}
|
| 83 |
+
{%- endmacro %}
|
| 84 |
+
{% macro broadcast_vector_load(name, shape, same, mode, g, acc, crosses, outputShape) -%}
|
| 85 |
+
{% if same %}
|
| 86 |
+
let {{ name }}v = vec4<{{ acc }}>({{ name }}[i4]);
|
| 87 |
+
{% elif mode == "scalar" %}
|
| 88 |
+
let {{ name }}v = vec4<{{ acc }}>({{ acc }}({{ name }}[0]));
|
| 89 |
+
{% elif g.active %}
|
| 90 |
+
let {{ name }}v = table_{{ name }}[i4 % {{ g.period }}u];
|
| 91 |
+
{% elif crosses %}
|
| 92 |
+
let {{ name }}v = vec4<{{ acc }}>(
|
| 93 |
+
{% for lane in range(4) %}
|
| 94 |
+
{{ acc }}({{ name }}[{{ broadcast_offset_call(name ~ "_offset", shape, outputShape, "base" if lane == 0 else "base + " ~ lane ~ "u") }}]){{ "," if lane < 3 else "" }}
|
| 95 |
+
{% endfor %}
|
| 96 |
+
);
|
| 97 |
+
{% elif mode == "splat" %}
|
| 98 |
+
let {{ name }}v = vec4<{{ acc }}>({{ acc }}({{ name }}[{{ broadcast_offset_call(name ~ "_offset", shape, outputShape, "base") }}]));
|
| 99 |
+
{% else %}
|
| 100 |
+
let {{ name }}o = {{ broadcast_offset_call(name ~ "_offset", shape, outputShape, "base") }};
|
| 101 |
+
let {{ name }}v = vec4<{{ acc }}>(
|
| 102 |
+
{% for lane in range(4) %}
|
| 103 |
+
{{ acc }}({{ name }}[{{ name }}o{% if lane != 0 %} + {{ lane }}u{% endif %}]){{ "," if lane < 3 else "" }}
|
| 104 |
+
{% endfor %}
|
| 105 |
+
);
|
| 106 |
+
{% endif %}
|
| 107 |
+
{%- endmacro %}
|
| 108 |
{{ env.wgsl.resourceDeclarations }}
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
{% set a_numel = namespace(value=1) %}
|
| 111 |
{% for d in aShape %}
|
| 112 |
{% set a_numel.value = a_numel.value * d %}
|
|
|
|
| 146 |
{% elif b_inner == 1 %}{% set b_mode = "splat" %}
|
| 147 |
{% else %}{% set b_mode = "contig" %}{% endif %}
|
| 148 |
|
| 149 |
+
{% set a_table = namespace(period=1, matching=true, active=false) %}
|
| 150 |
+
{% set b_table = namespace(period=1, matching=true, active=false) %}
|
| 151 |
+
{{ periodic_geometry(a_table, aShape, aRank, a_same.value, a_numel.value, cShape, cRank, crosses_inner_rows, periodicTableCap) }}
|
| 152 |
+
{{ periodic_geometry(b_table, bShape, bRank, b_same.value, b_numel.value, cShape, cRank, crosses_inner_rows, periodicTableCap) }}
|
| 153 |
+
{% if not a_same.value and a_mode != "scalar" and not a_table.active %}
|
| 154 |
{{ offset_fn("a_offset", aShape, aRank, false, a_numel.value, cShape, cRank, c_numel.value) }}
|
| 155 |
|
| 156 |
{% endif %}
|
| 157 |
+
{% if not b_same.value and b_mode != "scalar" and not b_table.active %}
|
| 158 |
{{ offset_fn("b_offset", bShape, bRank, false, b_numel.value, cShape, cRank, c_numel.value) }}
|
| 159 |
|
| 160 |
{% endif %}
|
|
|
|
| 171 |
{% else %}
|
| 172 |
{% set wrap = "" %}
|
| 173 |
{% endif %}
|
| 174 |
+
{{ periodic_declaration("a", a_table, acc) }}
|
| 175 |
+
{{ periodic_declaration("b", b_table, acc) }}
|
| 176 |
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
|
| 177 |
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>{% if a_table.active or b_table.active %}, @builtin(local_invocation_index) lid: u32{% endif %}) {
|
| 178 |
+
{{ periodic_stage("a", a_table, acc) }}
|
| 179 |
+
{{ periodic_stage("b", b_table, acc) }}
|
| 180 |
+
{% if a_table.active or b_table.active %}
|
| 181 |
+
workgroupBarrier();
|
| 182 |
+
{% endif %}
|
| 183 |
{{ flat_index_2d(tunables.WORKGROUP_SIZE, "i4") }}
|
| 184 |
+
{% set needsBase = c_numel.value != 0 and ((not a_same.value and a_mode != "scalar" and not a_table.active) or (not b_same.value and b_mode != "scalar" and not b_table.active and not (nativeTrailingB | default(false)))) %}
|
| 185 |
{% if needsBase %}
|
| 186 |
let base = i4 * 4u;
|
| 187 |
{% endif %}
|
| 188 |
+
{{ broadcast_vector_load("a", aShape, a_same.value, a_mode, a_table, acc, crosses_inner_rows, cShape) }}
|
| 189 |
+
{{ broadcast_vector_load("b", bShape, b_same.value, b_mode, b_table, acc, crosses_inner_rows, cShape) }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
{% if is_int %}
|
| 191 |
c[i4] = {{ wrap }}(vec4<{{ scalar }}>(av / bv));
|
| 192 |
{% else %}
|
| 193 |
let quotient = av / bv;
|
| 194 |
let rounded = round(quotient);
|
| 195 |
+
// Component-wise Div snap guard: f32 division can land slightly off an exact
|
| 196 |
// integer quotient, while half-integers must stay untouched.
|
| 197 |
let snapProduct = rounded * bv == av;
|
| 198 |
let snapClose = abs(quotient - rounded) < vec4<f32>(0.5);
|
build/webgpu/binary-broadcast.wgsl.jinja
CHANGED
|
@@ -10,7 +10,7 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
| 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 |
-
{%
|
| 14 |
{% macro flat_tail_close() %}
|
| 15 |
}{% endmacro %}
|
| 16 |
{% macro offset_fn(fn_name, opShape, opRank, op_same, op_numel, outShape, outRank, out_numel) %}
|
|
@@ -110,7 +110,7 @@ fn {{ fn_name }}({% if out_numel != 0 and op_numel != 1 %}out_index: u32{% endif
|
|
| 110 |
let bv = f32(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "i") }}]);
|
| 111 |
let quotient = av / bv;
|
| 112 |
let rounded = round(quotient);
|
| 113 |
-
//
|
| 114 |
// when the rounded quotient multiplies back exactly; half-integers stay
|
| 115 |
// untouched.
|
| 116 |
let snap = rounded * bv == av && abs(quotient - rounded) < 0.5;
|
|
|
|
| 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() %}
|
| 15 |
}{% endmacro %}
|
| 16 |
{% macro offset_fn(fn_name, opShape, opRank, op_same, op_numel, outShape, outRank, out_numel) %}
|
|
|
|
| 110 |
let bv = f32(b[{{ broadcast_offset_call("b_offset", bShape, cShape, "i") }}]);
|
| 111 |
let quotient = av / bv;
|
| 112 |
let rounded = round(quotient);
|
| 113 |
+
// f32 division can land slightly off an exact integer quotient. Snap only
|
| 114 |
// when the rounded quotient multiplies back exactly; half-integers stay
|
| 115 |
// untouched.
|
| 116 |
let snap = rounded * bv == av && abs(quotient - rounded) < 0.5;
|
build/webgpu/binary-vec4.wgsl.jinja
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
{{ env.wgsl.resourceDeclarations }}
|
| 2 |
|
| 3 |
-
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count"
|
| 4 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 5 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 6 |
// per-axis workgroup fold width.
|
| 7 |
-
{% if bound == "" %}
|
| 8 |
-
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};{% else %}
|
| 9 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
|
|
|
| 10 |
if ({{ name }} >= {{ bound }}) {
|
| 11 |
return;
|
| 12 |
-
}
|
|
|
|
|
|
|
| 13 |
{% if vec4PerThread > 1 %}
|
| 14 |
const ITEMS: u32 = {{ vec4PerThread }}u;
|
| 15 |
|
|
@@ -36,53 +46,42 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
| 36 |
{% else %}
|
| 37 |
{{ flat_index_2d(tunables.WORKGROUP_SIZE) }}
|
| 38 |
{% endif %}
|
| 39 |
-
{% set scalarOperand = scalarOperand if scalarOperand is defined else "" %}
|
| 40 |
{% if scalarOperand == "a" %}
|
| 41 |
-
|
| 42 |
-
|
| 43 |
{% else %}
|
| 44 |
-
|
| 45 |
{% endif %}
|
| 46 |
{% if scalarOperand == "b" %}
|
| 47 |
-
|
| 48 |
{% else %}
|
| 49 |
-
|
| 50 |
{% endif %}
|
| 51 |
{% if scalar == "i32" or scalar == "u32" %}
|
| 52 |
-
|
| 53 |
-
// Narrow integer operations wrap modulo the logical dtype width; int8/uint8
|
| 54 |
-
// use i32/u32 storage.
|
| 55 |
{% if cDtype == "int8" %}
|
| 56 |
-
|
| 57 |
{% elif cDtype == "uint8" %}
|
| 58 |
-
|
| 59 |
{% else %}
|
| 60 |
-
|
| 61 |
{% endif %}
|
| 62 |
{% elif scalar == "f16" %}
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
select(quotient.x, rounded.x, snapProduct.x && snapClose.x),
|
| 71 |
-
select(quotient.y, rounded.y, snapProduct.y && snapClose.y),
|
| 72 |
-
select(quotient.z, rounded.z, snapProduct.z && snapClose.z),
|
| 73 |
-
select(quotient.w, rounded.w, snapProduct.w && snapClose.w)
|
| 74 |
-
));
|
| 75 |
{% else %}
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
select(quotient.x, rounded.x, snapProduct.x && snapClose.x),
|
| 82 |
-
select(quotient.y, rounded.y, snapProduct.y && snapClose.y),
|
| 83 |
-
select(quotient.z, rounded.z, snapProduct.z && snapClose.z),
|
| 84 |
-
select(quotient.w, rounded.w, snapProduct.w && snapClose.w)
|
| 85 |
-
);
|
| 86 |
{% endif %}
|
| 87 |
{% if vec4PerThread > 1 %}
|
| 88 |
}
|
|
|
|
| 1 |
+
{% set binaryOperator = "/" %}
|
| 2 |
+
{% macro binary_snapped_quotient() %}
|
| 3 |
+
vec4<f32>(
|
| 4 |
+
{% for lane in ["x", "y", "z", "w"] %}
|
| 5 |
+
select(quotient.{{ lane }}, rounded.{{ lane }}, snapProduct.{{ lane }} && snapClose.{{ lane }}){{ "," if not loop.last else "" }}
|
| 6 |
+
{% endfor %}
|
| 7 |
+
)
|
| 8 |
+
{%- endmacro %}
|
| 9 |
+
|
| 10 |
{{ env.wgsl.resourceDeclarations }}
|
| 11 |
|
| 12 |
+
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count") %}
|
| 13 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 14 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 15 |
// per-axis workgroup fold width.
|
|
|
|
|
|
|
| 16 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 17 |
+
{% if bound != "" %}
|
| 18 |
if ({{ name }} >= {{ bound }}) {
|
| 19 |
return;
|
| 20 |
+
}
|
| 21 |
+
{% endif %}
|
| 22 |
+
{% endmacro %}
|
| 23 |
{% if vec4PerThread > 1 %}
|
| 24 |
const ITEMS: u32 = {{ vec4PerThread }}u;
|
| 25 |
|
|
|
|
| 46 |
{% else %}
|
| 47 |
{{ flat_index_2d(tunables.WORKGROUP_SIZE) }}
|
| 48 |
{% endif %}
|
|
|
|
| 49 |
{% if scalarOperand == "a" %}
|
| 50 |
+
// One-element operand: read once and splat across the vector.
|
| 51 |
+
let av = {{ vectorScalar }}(a[0]);
|
| 52 |
{% else %}
|
| 53 |
+
let av = a[i];
|
| 54 |
{% endif %}
|
| 55 |
{% if scalarOperand == "b" %}
|
| 56 |
+
let bv = {{ vectorScalar }}(b[0]);
|
| 57 |
{% else %}
|
| 58 |
+
let bv = b[i];
|
| 59 |
{% endif %}
|
| 60 |
{% if scalar == "i32" or scalar == "u32" %}
|
| 61 |
+
let r = av {{ binaryOperator }} bv;
|
| 62 |
+
// Narrow integer operations wrap modulo the logical dtype width; int8/uint8
|
| 63 |
+
// use i32/u32 storage.
|
| 64 |
{% if cDtype == "int8" %}
|
| 65 |
+
c[i] = (r << vec4<u32>(24u)) >> vec4<u32>(24u);
|
| 66 |
{% elif cDtype == "uint8" %}
|
| 67 |
+
c[i] = r & vec4<u32>(0xFFu);
|
| 68 |
{% else %}
|
| 69 |
+
c[i] = r;
|
| 70 |
{% endif %}
|
| 71 |
{% elif scalar == "f16" %}
|
| 72 |
+
let avf = vec4<f32>(av);
|
| 73 |
+
let bvf = vec4<f32>(bv);
|
| 74 |
+
let quotient = avf / bvf;
|
| 75 |
+
let rounded = round(quotient);
|
| 76 |
+
let snapProduct = rounded * bvf == avf;
|
| 77 |
+
let snapClose = abs(quotient - rounded) < vec4<f32>(0.5);
|
| 78 |
+
c[i] = vec4<f16>({{ binary_snapped_quotient() }});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
{% else %}
|
| 80 |
+
let quotient = av / bv;
|
| 81 |
+
let rounded = round(quotient);
|
| 82 |
+
let snapProduct = rounded * bv == av;
|
| 83 |
+
let snapClose = abs(quotient - rounded) < vec4<f32>(0.5);
|
| 84 |
+
c[i] = {{ binary_snapped_quotient() }};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
{% endif %}
|
| 86 |
{% if vec4PerThread > 1 %}
|
| 87 |
}
|
build/webgpu/manifest.json
CHANGED
|
@@ -1,163 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"domain": "ai.onnx",
|
| 3 |
-
"name": "Div",
|
| 4 |
-
"sinceVersion": 14,
|
| 5 |
-
"inputs": { "a": { "onnx": "A", "dtype": "T" }, "b": { "onnx": "B", "dtype": "T" } },
|
| 6 |
-
"outputs": {
|
| 7 |
-
"c": { "onnx": "C", "dtype": "T", "rank": "max(ranks.a, ranks.b)", "shape": "broadcastShape(shapes.a, shapes.b)" }
|
| 8 |
-
},
|
| 9 |
-
"typeConstraints": { "T": ["float32", "float16", "int32", "uint32", "int8", "uint8"] },
|
| 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": { "scalar": "dtypes.T", "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" },
|
| 17 |
-
"passes": [
|
| 18 |
-
{
|
| 19 |
-
"id": "main",
|
| 20 |
-
"name": "Div.Vec4",
|
| 21 |
-
"shader": "binary-vec4.wgsl.jinja",
|
| 22 |
-
"derive": {
|
| 23 |
-
"op": "\"div\"",
|
| 24 |
-
"cDtype": "tensorDtypes.c",
|
| 25 |
-
"vec4PerThread": "4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"
|
| 26 |
-
},
|
| 27 |
-
"bindings": ["a", "b", "c_binary", "params"],
|
| 28 |
-
"dispatch": {
|
| 29 |
-
"x": "min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 30 |
-
"y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 31 |
-
"z": 1
|
| 32 |
-
}
|
| 33 |
-
}
|
| 34 |
-
]
|
| 35 |
-
},
|
| 36 |
-
{
|
| 37 |
-
"id": "scalar_b_vec4",
|
| 38 |
-
"priority": 18,
|
| 39 |
-
"when": ["sameShape(shapes.a, shapes.c)", "numel(shapes.b) == 1", "numel(shapes.c) > 0", "numel(shapes.c) % 4 == 0", "f16Ok(dtypes.T)"],
|
| 40 |
-
"derive": { "scalar": "dtypes.T", "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" },
|
| 41 |
-
"passes": [
|
| 42 |
-
{
|
| 43 |
-
"id": "main",
|
| 44 |
-
"name": "Div.ScalarBVec4",
|
| 45 |
-
"shader": "binary-vec4.wgsl.jinja",
|
| 46 |
-
"derive": {
|
| 47 |
-
"op": "\"div\"",
|
| 48 |
-
"cDtype": "tensorDtypes.c",
|
| 49 |
-
"scalarOperand": "\"b\"",
|
| 50 |
-
"vec4PerThread": "4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"
|
| 51 |
-
},
|
| 52 |
-
"bindings": ["a", "b_scalar", "c_binary", "params"],
|
| 53 |
-
"dispatch": {
|
| 54 |
-
"x": "min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 55 |
-
"y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 56 |
-
"z": 1
|
| 57 |
-
}
|
| 58 |
-
}
|
| 59 |
-
]
|
| 60 |
-
},
|
| 61 |
-
{
|
| 62 |
-
"id": "scalar_a_vec4",
|
| 63 |
-
"priority": 18,
|
| 64 |
-
"when": ["sameShape(shapes.b, shapes.c)", "numel(shapes.a) == 1", "numel(shapes.c) > 0", "numel(shapes.c) % 4 == 0", "f16Ok(dtypes.T)"],
|
| 65 |
-
"derive": { "scalar": "dtypes.T", "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" },
|
| 66 |
-
"passes": [
|
| 67 |
-
{
|
| 68 |
-
"id": "main",
|
| 69 |
-
"name": "Div.ScalarAVec4",
|
| 70 |
-
"shader": "binary-vec4.wgsl.jinja",
|
| 71 |
-
"derive": {
|
| 72 |
-
"op": "\"div\"",
|
| 73 |
-
"cDtype": "tensorDtypes.c",
|
| 74 |
-
"scalarOperand": "\"a\"",
|
| 75 |
-
"vec4PerThread": "4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"
|
| 76 |
-
},
|
| 77 |
-
"bindings": ["a_scalar", "b", "c_binary", "params"],
|
| 78 |
-
"dispatch": {
|
| 79 |
-
"x": "min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 80 |
-
"y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 81 |
-
"z": 1
|
| 82 |
-
}
|
| 83 |
-
}
|
| 84 |
-
]
|
| 85 |
-
},
|
| 86 |
-
{
|
| 87 |
-
"id": "broadcast_vec4",
|
| 88 |
-
"priority": 10,
|
| 89 |
-
"when": ["ranks.a <= ranks.c", "ranks.b <= ranks.c", "ranks.c >= 1", "numel(shapes.c) % 4 == 0", "numel(shapes.c) >= 4", "f16Ok(dtypes.T)"],
|
| 90 |
-
"derive": {
|
| 91 |
-
"scalar": "dtypes.T",
|
| 92 |
-
"aElement": "\"vec4<\" ~ dtypes.T ~ \">\" if sameShape(shapes.a, shapes.c) else dtypes.T",
|
| 93 |
-
"bElement": "\"vec4<\" ~ dtypes.T ~ \">\" if sameShape(shapes.b, shapes.c) else dtypes.T",
|
| 94 |
-
"vec4Scalar": "\"vec4<\" ~ dtypes.T ~ \">\""
|
| 95 |
-
},
|
| 96 |
-
"passes": [
|
| 97 |
-
{
|
| 98 |
-
"id": "main",
|
| 99 |
-
"name": "Div",
|
| 100 |
-
"shader": "binary-broadcast-vec4.wgsl.jinja",
|
| 101 |
-
"derive": {
|
| 102 |
-
"aShape": "shapes.a",
|
| 103 |
-
"bShape": "shapes.b",
|
| 104 |
-
"cShape": "shapes.c",
|
| 105 |
-
"aRank": "ranks.a",
|
| 106 |
-
"bRank": "ranks.b",
|
| 107 |
-
"cRank": "ranks.c",
|
| 108 |
-
"op": "\"div\"",
|
| 109 |
-
"cDtype": "tensorDtypes.c"
|
| 110 |
-
},
|
| 111 |
-
"bindings": ["a_element", "b_element", "c_2_binary", "params"],
|
| 112 |
-
"dispatch": {
|
| 113 |
-
"x": "min(ceilDiv((numel(shapes.c) / 4), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 114 |
-
"y": "ceilDiv(ceilDiv((numel(shapes.c) / 4), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 115 |
-
"z": 1
|
| 116 |
-
}
|
| 117 |
-
}
|
| 118 |
-
]
|
| 119 |
-
},
|
| 120 |
-
{
|
| 121 |
-
"id": "broadcast",
|
| 122 |
-
"when": ["ranks.a <= ranks.c", "ranks.b <= ranks.c", "f16Ok(dtypes.T)"],
|
| 123 |
-
"derive": { "scalar": "dtypes.T" },
|
| 124 |
-
"passes": [
|
| 125 |
-
{
|
| 126 |
-
"id": "main",
|
| 127 |
-
"name": "Div",
|
| 128 |
-
"shader": "binary-broadcast.wgsl.jinja",
|
| 129 |
-
"derive": {
|
| 130 |
-
"aShape": "shapes.a",
|
| 131 |
-
"bShape": "shapes.b",
|
| 132 |
-
"cShape": "shapes.c",
|
| 133 |
-
"aRank": "ranks.a",
|
| 134 |
-
"bRank": "ranks.b",
|
| 135 |
-
"cRank": "ranks.c",
|
| 136 |
-
"op": "\"div\"",
|
| 137 |
-
"cDtype": "tensorDtypes.c",
|
| 138 |
-
"itemsPerInvocation": 4
|
| 139 |
-
},
|
| 140 |
-
"bindings": ["a_scalar", "b_scalar", "c_scalar", "params_count"],
|
| 141 |
-
"dispatch": {
|
| 142 |
-
"x": "min(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 143 |
-
"y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 144 |
-
"z": 1
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
-
]
|
| 148 |
-
}
|
| 149 |
-
],
|
| 150 |
-
"bindings": {
|
| 151 |
-
"a": { "elementType": "$vectorScalar" },
|
| 152 |
-
"b": { "elementType": "$vectorScalar" },
|
| 153 |
-
"c_binary": { "elementType": "$vectorScalar", "name": "c" },
|
| 154 |
-
"params": { "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.c) / 4" }] },
|
| 155 |
-
"b_scalar": { "name": "b", "elementType": "$scalar" },
|
| 156 |
-
"a_scalar": { "name": "a", "elementType": "$scalar" },
|
| 157 |
-
"a_element": { "name": "a", "elementType": "$aElement" },
|
| 158 |
-
"b_element": { "name": "b", "elementType": "$bElement" },
|
| 159 |
-
"c_2_binary": { "name": "c", "elementType": "$vec4Scalar" },
|
| 160 |
-
"c_scalar": { "name": "c", "elementType": "$scalar" },
|
| 161 |
-
"params_count": { "name": "params", "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.c)" }] }
|
| 162 |
-
}
|
| 163 |
-
}
|
|
|
|
| 1 |
+
{"domain":"ai.onnx","name":"Div","sinceVersion":14,"inputs":{"a":{"onnx":"A","dtype":"T"},"b":{"onnx":"B","dtype":"T"}},"outputs":{"c":{"onnx":"C","dtype":"T","rank":"max(ranks.a, ranks.b)","shape":"broadcastShape(shapes.a, shapes.b)"}},"typeConstraints":{"T":["float32","float16","int32","uint32","int8","uint8"]},"tunables":{"WORKGROUP_SIZE":{"default":256}},"variants":[{"id":"same_shape_vec4","priority":20,"when":["sameShape(shapes.a, shapes.c) or sameShape(shapes.b, shapes.c)","sameShape(shapes.a, shapes.c) or numel(shapes.a) == 1","sameShape(shapes.b, shapes.c) or numel(shapes.b) == 1","numel(shapes.c) > 0","numel(shapes.c) % 4 == 0","f16Ok(dtypes.T)"],"derive":{"scalar":"dtypes.T","vectorScalar":"\"vec4<\" ~ dtypes.T ~ \">\"","aElement":"vectorScalar if sameShape(shapes.a, shapes.c) else dtypes.T","bElement":"vectorScalar if sameShape(shapes.b, shapes.c) else dtypes.T"},"passes":[{"id":"main","name":"Div.Vec4","shader":"binary-vec4.wgsl.jinja","derive":{"cDtype":"tensorDtypes.c","scalarOperand":"\"a\" if not sameShape(shapes.a, shapes.c) else (\"b\" if not sameShape(shapes.b, shapes.c) else \"\")","vec4PerThread":"4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"},"bindings":["a_element","b_element","c_binary","params"],"dispatch":{"x":"min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]},{"id":"broadcast_vec4","priority":10,"when":["ranks.a <= ranks.c","ranks.b <= ranks.c","ranks.c >= 1","numel(shapes.c) % 4 == 0","numel(shapes.c) >= 4","f16Ok(dtypes.T)"],"derive":{"scalar":"dtypes.T","aElement":"\"vec4<\" ~ dtypes.T ~ \">\" if sameShape(shapes.a, shapes.c) else dtypes.T","bElement":"\"vec4<\" ~ dtypes.T ~ \">\" if sameShape(shapes.b, shapes.c) else dtypes.T","vec4Scalar":"\"vec4<\" ~ dtypes.T ~ \">\""},"passes":[{"id":"main","name":"Div","shader":"binary-broadcast-vec4.wgsl.jinja","derive":{"aShape":"shapes.a","bShape":"shapes.b","cShape":"shapes.c","aRank":"ranks.a","bRank":"ranks.b","cRank":"ranks.c","cDtype":"tensorDtypes.c","periodicTableCap":"min(floor(tunables.WORKGROUP_SIZE / 2), floor(device.limits.maxComputeWorkgroupStorageSize / 32)) if numel(shapes.c) >= 4 * tunables.WORKGROUP_SIZE else 0"},"bindings":["a_element","b_element","c_2_binary","params"],"dispatch":{"x":"min(ceilDiv((numel(shapes.c) / 4), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((numel(shapes.c) / 4), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]},{"id":"broadcast","when":["ranks.a <= ranks.c","ranks.b <= ranks.c","f16Ok(dtypes.T)"],"derive":{"scalar":"dtypes.T"},"passes":[{"id":"main","name":"Div","shader":"binary-broadcast.wgsl.jinja","derive":{"aShape":"shapes.a","bShape":"shapes.b","cShape":"shapes.c","aRank":"ranks.a","bRank":"ranks.b","cRank":"ranks.c","cDtype":"tensorDtypes.c","itemsPerInvocation":4},"bindings":["a_scalar","b_scalar","c_scalar","params_count"],"dispatch":{"x":"min(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]}],"bindings":{"c_binary":{"elementType":"$vectorScalar","name":"c"},"params":{"struct":[{"name":"count","type":"u32","value":"numel(shapes.c) / 4"}]},"b_scalar":{"name":"b","elementType":"$scalar"},"a_scalar":{"name":"a","elementType":"$scalar"},"a_element":{"name":"a","elementType":"$aElement"},"b_element":{"name":"b","elementType":"$bElement"},"c_2_binary":{"name":"c","elementType":"$vec4Scalar"},"c_scalar":{"name":"c","elementType":"$scalar"},"params_count":{"name":"params","struct":[{"name":"count","type":"u32","value":"numel(shapes.c)"}]}}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/webgpu/metadata.json
CHANGED
|
@@ -1,29 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "ai.onnx.Div",
|
| 3 |
-
"id": "_ai_onnx_div_webgpu_c547c0c",
|
| 4 |
-
"version": 1,
|
| 5 |
-
"license": "Apache-2.0",
|
| 6 |
-
"backend": { "type": "webgpu" },
|
| 7 |
-
"digest": {
|
| 8 |
-
"algorithm": "sha256",
|
| 9 |
-
"files": {
|
| 10 |
-
"bench.json": "P9M5ABblrxZXFebRyjROuEvlMZ9Dj/gfBV536o28y0c=",
|
| 11 |
-
"binary-broadcast-vec4.wgsl.jinja": "dOZLpNyRm1hXLcT5XtD7XVouSqxgXVgansxkuYY56UA=",
|
| 12 |
-
"binary-broadcast.wgsl.jinja": "3/Lo28fE2lFmmAxBi9Kv5wAnHUV5O6DFKg8FiMUoal4=",
|
| 13 |
-
"binary-vec4.wgsl.jinja": "MYhQAd0gTjW8FnJJyAKr/7JjFtLYoR/ATG+xSb5akTA=",
|
| 14 |
-
"manifest.json": "qoS6dzk5Gpkw7ru9z7ZKIcZXSh0tVlD05XZ4NkINdUI=",
|
| 15 |
-
"test.json": "chltuf8PTycWeh+JsnMl1o5jsnTYNmdi/46adzbUq6U="
|
| 16 |
-
}
|
| 17 |
-
},
|
| 18 |
-
"provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } },
|
| 19 |
-
"webgpu": {
|
| 20 |
-
"manifestSpec": "2.1",
|
| 21 |
-
"variants": {
|
| 22 |
-
"same_shape_vec4": ["binary-vec4.wgsl.jinja"],
|
| 23 |
-
"scalar_b_vec4": ["binary-vec4.wgsl.jinja"],
|
| 24 |
-
"scalar_a_vec4": ["binary-vec4.wgsl.jinja"],
|
| 25 |
-
"broadcast_vec4": ["binary-broadcast-vec4.wgsl.jinja"],
|
| 26 |
-
"broadcast": ["binary-broadcast.wgsl.jinja"]
|
| 27 |
-
}
|
| 28 |
-
}
|
| 29 |
-
}
|
|
|
|
| 1 |
+
{"name":"ai.onnx.Div","id":"_ai_onnx_div_webgpu_4a3f205","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"5qXOevhX3/f+YBhfUFLi0zWnDQlvN3l36bqMxcyZ1c4=","binary-broadcast-vec4.wgsl.jinja":"W1+Wc3vWhHiNjKB64f8a0jZ8uhg6Th1xUc7FfEJ0r6U=","binary-broadcast.wgsl.jinja":"+5WvfZVFD8VLaOK6IAr9gBClK6hypofTAz3HgjfHXIY=","binary-vec4.wgsl.jinja":"KQegn70qPslgvtA3gx7NQW1sRU+O0RXtMi0KMOVXonw=","manifest.json":"fR4BcFDkCbCoHtSjwTmzjDyG2RlsCvA1k4GbI7OTJ6U=","test.json":"pqD79PIcmq9+2SZUBYf82fp+aLlT5BBdzFDvi+KZ4Lk="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/webgpu/test.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
{
|
| 2 |
"fixtureArrays": {
|
| 3 |
-
"onnx_backend_div_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 |
},
|
| 5 |
"cases": [
|
| 6 |
{
|
|
@@ -426,7 +429,7 @@
|
|
| 426 |
"name": "ort_int16_basic_truncates_toward_zero_gpu_gap",
|
| 427 |
"skipGpu": {
|
| 428 |
"category": "todo",
|
| 429 |
-
"reason": "
|
| 430 |
},
|
| 431 |
"provenance": {
|
| 432 |
"source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
|
|
@@ -546,6 +549,232 @@
|
|
| 546 |
}
|
| 547 |
},
|
| 548 |
"outputs": { "c": { "dtype": "float32", "shape": [2, 8], "tolerance": 0.000001 } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 549 |
}
|
| 550 |
]
|
| 551 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"fixtureArrays": {
|
| 3 |
+
"onnx_backend_div_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 |
+
"periodic_signed_values": [-121, -97, -53, -17, 31, 67, 103, 127],
|
| 5 |
+
"periodic_unsigned_values": [1, 7, 31, 59, 97, 131, 211, 251],
|
| 6 |
+
"periodic_divisors": [2, 3, 5, 7, 11, 13, 17]
|
| 7 |
},
|
| 8 |
"cases": [
|
| 9 |
{
|
|
|
|
| 429 |
"name": "ort_int16_basic_truncates_toward_zero_gpu_gap",
|
| 430 |
"skipGpu": {
|
| 431 |
"category": "todo",
|
| 432 |
+
"reason": "int16 Div is not supported on GPU yet: it needs explicit handling of signed 16-bit narrowing and overflow, including INT16_MIN / -1."
|
| 433 |
},
|
| 434 |
"provenance": {
|
| 435 |
"source": "onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc",
|
|
|
|
| 549 |
}
|
| 550 |
},
|
| 551 |
"outputs": { "c": { "dtype": "float32", "shape": [2, 8], "tolerance": 0.000001 } }
|
| 552 |
+
},
|
| 553 |
+
{
|
| 554 |
+
"name": "periodic_f32_rhs_p5",
|
| 555 |
+
"inputs": {
|
| 556 |
+
"a": {
|
| 557 |
+
"dtype": "float32",
|
| 558 |
+
"shape": [4, 55, 5],
|
| 559 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 560 |
+
},
|
| 561 |
+
"b": {
|
| 562 |
+
"dtype": "float32",
|
| 563 |
+
"shape": [1, 1, 5],
|
| 564 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 565 |
+
}
|
| 566 |
+
},
|
| 567 |
+
"outputs": { "c": { "dtype": "float32", "shape": [4, 55, 5], "tolerance": 0.000001 } }
|
| 568 |
+
},
|
| 569 |
+
{
|
| 570 |
+
"name": "periodic_f16_rhs_p13",
|
| 571 |
+
"inputs": {
|
| 572 |
+
"a": {
|
| 573 |
+
"dtype": "float16",
|
| 574 |
+
"shape": [4, 31, 13],
|
| 575 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 576 |
+
},
|
| 577 |
+
"b": {
|
| 578 |
+
"dtype": "float16",
|
| 579 |
+
"shape": [13],
|
| 580 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 581 |
+
}
|
| 582 |
+
},
|
| 583 |
+
"outputs": { "c": { "dtype": "float16", "shape": [4, 31, 13], "tolerance": 0.002 } }
|
| 584 |
+
},
|
| 585 |
+
{
|
| 586 |
+
"name": "periodic_i32_lhs_p7",
|
| 587 |
+
"inputs": {
|
| 588 |
+
"a": {
|
| 589 |
+
"dtype": "int32",
|
| 590 |
+
"shape": [7],
|
| 591 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_signed_values" } }
|
| 592 |
+
},
|
| 593 |
+
"b": {
|
| 594 |
+
"dtype": "int32",
|
| 595 |
+
"shape": [4, 53, 7],
|
| 596 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_divisors" } }
|
| 597 |
+
}
|
| 598 |
+
},
|
| 599 |
+
"outputs": { "c": { "dtype": "int32", "shape": [4, 53, 7], "tolerance": 0 } }
|
| 600 |
+
},
|
| 601 |
+
{
|
| 602 |
+
"name": "periodic_u32_rhs_p6",
|
| 603 |
+
"inputs": {
|
| 604 |
+
"a": {
|
| 605 |
+
"dtype": "uint32",
|
| 606 |
+
"shape": [4, 51, 6],
|
| 607 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_unsigned_values" } }
|
| 608 |
+
},
|
| 609 |
+
"b": {
|
| 610 |
+
"dtype": "uint32",
|
| 611 |
+
"shape": [1, 6],
|
| 612 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_divisors" } }
|
| 613 |
+
}
|
| 614 |
+
},
|
| 615 |
+
"outputs": { "c": { "dtype": "uint32", "shape": [4, 51, 6], "tolerance": 0 } }
|
| 616 |
+
},
|
| 617 |
+
{
|
| 618 |
+
"name": "periodic_i8_rhs_p5",
|
| 619 |
+
"inputs": {
|
| 620 |
+
"a": {
|
| 621 |
+
"dtype": "int8",
|
| 622 |
+
"shape": [4, 57, 5],
|
| 623 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_signed_values" } }
|
| 624 |
+
},
|
| 625 |
+
"b": {
|
| 626 |
+
"dtype": "int8",
|
| 627 |
+
"shape": [5],
|
| 628 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_divisors" } }
|
| 629 |
+
}
|
| 630 |
+
},
|
| 631 |
+
"outputs": { "c": { "dtype": "int8", "shape": [4, 57, 5], "tolerance": 0 } }
|
| 632 |
+
},
|
| 633 |
+
{
|
| 634 |
+
"name": "periodic_u8_lhs_p9",
|
| 635 |
+
"inputs": {
|
| 636 |
+
"a": {
|
| 637 |
+
"dtype": "uint8",
|
| 638 |
+
"shape": [1, 9],
|
| 639 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_unsigned_values" } }
|
| 640 |
+
},
|
| 641 |
+
"b": {
|
| 642 |
+
"dtype": "uint8",
|
| 643 |
+
"shape": [4, 33, 9],
|
| 644 |
+
"data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/periodic_divisors" } }
|
| 645 |
+
}
|
| 646 |
+
},
|
| 647 |
+
"outputs": { "c": { "dtype": "uint8", "shape": [4, 33, 9], "tolerance": 0 } }
|
| 648 |
+
},
|
| 649 |
+
{
|
| 650 |
+
"name": "periodic_f32_suffix2_p15",
|
| 651 |
+
"inputs": {
|
| 652 |
+
"a": {
|
| 653 |
+
"dtype": "float32",
|
| 654 |
+
"shape": [4, 19, 3, 5],
|
| 655 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 656 |
+
},
|
| 657 |
+
"b": {
|
| 658 |
+
"dtype": "float32",
|
| 659 |
+
"shape": [3, 5],
|
| 660 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 661 |
+
}
|
| 662 |
+
},
|
| 663 |
+
"outputs": { "c": { "dtype": "float32", "shape": [4, 19, 3, 5], "tolerance": 0.000001 } }
|
| 664 |
+
},
|
| 665 |
+
{
|
| 666 |
+
"name": "periodic_f32_cap_p63",
|
| 667 |
+
"inputs": {
|
| 668 |
+
"a": {
|
| 669 |
+
"dtype": "float32",
|
| 670 |
+
"shape": [4, 5, 63],
|
| 671 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 672 |
+
},
|
| 673 |
+
"b": {
|
| 674 |
+
"dtype": "float32",
|
| 675 |
+
"shape": [63],
|
| 676 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 677 |
+
}
|
| 678 |
+
},
|
| 679 |
+
"outputs": { "c": { "dtype": "float32", "shape": [4, 5, 63], "tolerance": 0.000001 } }
|
| 680 |
+
},
|
| 681 |
+
{
|
| 682 |
+
"name": "periodic_f32_overcap_p65",
|
| 683 |
+
"inputs": {
|
| 684 |
+
"a": {
|
| 685 |
+
"dtype": "float32",
|
| 686 |
+
"shape": [4, 5, 65],
|
| 687 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 688 |
+
},
|
| 689 |
+
"b": {
|
| 690 |
+
"dtype": "float32",
|
| 691 |
+
"shape": [65],
|
| 692 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 693 |
+
}
|
| 694 |
+
},
|
| 695 |
+
"outputs": { "c": { "dtype": "float32", "shape": [4, 5, 65], "tolerance": 0.000001 } }
|
| 696 |
+
},
|
| 697 |
+
{
|
| 698 |
+
"name": "periodic_f32_wg64_cap_p15",
|
| 699 |
+
"inputs": {
|
| 700 |
+
"a": {
|
| 701 |
+
"dtype": "float32",
|
| 702 |
+
"shape": [4, 7, 15],
|
| 703 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 704 |
+
},
|
| 705 |
+
"b": {
|
| 706 |
+
"dtype": "float32",
|
| 707 |
+
"shape": [15],
|
| 708 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 709 |
+
}
|
| 710 |
+
},
|
| 711 |
+
"outputs": { "c": { "dtype": "float32", "shape": [4, 7, 15], "tolerance": 0.000001 } },
|
| 712 |
+
"tunables": { "WORKGROUP_SIZE": 64 }
|
| 713 |
+
},
|
| 714 |
+
{
|
| 715 |
+
"name": "periodic_f32_wg64_overcap_p17",
|
| 716 |
+
"inputs": {
|
| 717 |
+
"a": {
|
| 718 |
+
"dtype": "float32",
|
| 719 |
+
"shape": [4, 7, 17],
|
| 720 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 721 |
+
},
|
| 722 |
+
"b": {
|
| 723 |
+
"dtype": "float32",
|
| 724 |
+
"shape": [17],
|
| 725 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 726 |
+
}
|
| 727 |
+
},
|
| 728 |
+
"outputs": { "c": { "dtype": "float32", "shape": [4, 7, 17], "tolerance": 0.000001 } },
|
| 729 |
+
"tunables": { "WORKGROUP_SIZE": 64 }
|
| 730 |
+
},
|
| 731 |
+
{
|
| 732 |
+
"name": "periodic_f32_small_p13",
|
| 733 |
+
"inputs": {
|
| 734 |
+
"a": {
|
| 735 |
+
"dtype": "float32",
|
| 736 |
+
"shape": [4, 13],
|
| 737 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 738 |
+
},
|
| 739 |
+
"b": {
|
| 740 |
+
"dtype": "float32",
|
| 741 |
+
"shape": [13],
|
| 742 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 743 |
+
}
|
| 744 |
+
},
|
| 745 |
+
"outputs": { "c": { "dtype": "float32", "shape": [4, 13], "tolerance": 0.000001 } }
|
| 746 |
+
},
|
| 747 |
+
{
|
| 748 |
+
"name": "periodic_f32_tail_scalar_p13",
|
| 749 |
+
"inputs": {
|
| 750 |
+
"a": {
|
| 751 |
+
"dtype": "float32",
|
| 752 |
+
"shape": [3, 13],
|
| 753 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 754 |
+
},
|
| 755 |
+
"b": {
|
| 756 |
+
"dtype": "float32",
|
| 757 |
+
"shape": [13],
|
| 758 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 759 |
+
}
|
| 760 |
+
},
|
| 761 |
+
"outputs": { "c": { "dtype": "float32", "shape": [3, 13], "tolerance": 0.000001 } }
|
| 762 |
+
},
|
| 763 |
+
{
|
| 764 |
+
"name": "periodic_full_f32_p13",
|
| 765 |
+
"inputs": {
|
| 766 |
+
"a": {
|
| 767 |
+
"dtype": "float32",
|
| 768 |
+
"shape": [512, 512, 13],
|
| 769 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.23, "offset": 4.0, "scale": 0.5 }
|
| 770 |
+
},
|
| 771 |
+
"b": {
|
| 772 |
+
"dtype": "float32",
|
| 773 |
+
"shape": [1, 1, 13],
|
| 774 |
+
"data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.11, "offset": 1.0, "scale": 0.5 }
|
| 775 |
+
}
|
| 776 |
+
},
|
| 777 |
+
"outputs": { "c": { "dtype": "float32", "shape": [512, 512, 13], "tolerance": 0.000001 } }
|
| 778 |
}
|
| 779 |
]
|
| 780 |
}
|