sync 4385228f788d
Browse files- README.md +12 -8
- build/webgpu/elementwise-bias-gelu.wgsl.jinja +12 -6
- build/webgpu/manifest.json +1 -58
- build/webgpu/metadata.json +1 -21
- build/webgpu/test.json +112 -6
README.md
CHANGED
|
@@ -36,28 +36,32 @@ See the [ONNX Runtime `Gelu` contrib-operator spec](https://github.com/microsoft
|
|
| 36 |
|
| 37 |
## Files
|
| 38 |
|
| 39 |
-
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests,
|
| 40 |
-
- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
|
| 41 |
-
- [`test.json`](build/webgpu/test.json) — correctness cases
|
| 42 |
-
- [`bench.json`](build/webgpu/bench.json) — benchmark cases
|
| 43 |
-
- [`elementwise-bias-gelu.wgsl.jinja`](build/webgpu/elementwise-bias-gelu.wgsl.jinja)
|
| 44 |
|
| 45 |
## Use with `@huggingface/kernels`
|
| 46 |
|
| 47 |
```sh
|
| 48 |
-
npm install --save-exact @huggingface/kernels@0.0.1-preview.
|
| 49 |
```
|
| 50 |
|
|
|
|
|
|
|
| 51 |
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
|
| 52 |
|
| 53 |
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 54 |
It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
|
| 55 |
|
| 56 |
-
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
|
| 57 |
-
|
| 58 |
```js
|
| 59 |
import { getKernel } from "@huggingface/kernels";
|
| 60 |
|
| 61 |
const kernel = await getKernel("webgpu-kernels/com.microsoft.Gelu", { version: 1 });
|
|
|
|
|
|
|
|
|
|
| 62 |
const { Y } = await kernel({ X: { data: XData, shape: [5] } });
|
|
|
|
| 63 |
```
|
|
|
|
| 36 |
|
| 37 |
## Files
|
| 38 |
|
| 39 |
+
- [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.Gelu/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)
|
| 40 |
+
- [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.Gelu/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)
|
| 41 |
+
- [`test.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.Gelu/blob/v1/build/webgpu/test.json) — correctness cases
|
| 42 |
+
- [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.Gelu/blob/v1/build/webgpu/bench.json) — benchmark cases
|
| 43 |
+
- [`elementwise-bias-gelu.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.Gelu/blob/v1/build/webgpu/elementwise-bias-gelu.wgsl.jinja)
|
| 44 |
|
| 45 |
## Use with `@huggingface/kernels`
|
| 46 |
|
| 47 |
```sh
|
| 48 |
+
npm install --save-exact @huggingface/kernels@0.0.1-preview.4
|
| 49 |
```
|
| 50 |
|
| 51 |
+
Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.
|
| 52 |
+
|
| 53 |
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
|
| 54 |
|
| 55 |
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 56 |
It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
|
| 57 |
|
|
|
|
|
|
|
| 58 |
```js
|
| 59 |
import { getKernel } from "@huggingface/kernels";
|
| 60 |
|
| 61 |
const kernel = await getKernel("webgpu-kernels/com.microsoft.Gelu", { version: 1 });
|
| 62 |
+
|
| 63 |
+
const XData = Float32Array.of(-Infinity, Infinity, NaN, 0, 0);
|
| 64 |
+
|
| 65 |
const { Y } = await kernel({ X: { data: XData, shape: [5] } });
|
| 66 |
+
console.log({ Y });
|
| 67 |
```
|
build/webgpu/elementwise-bias-gelu.wgsl.jinja
CHANGED
|
@@ -1,18 +1,20 @@
|
|
| 1 |
-
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count"
|
| 2 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 3 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 4 |
// per-axis workgroup fold width.
|
| 5 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 6 |
if ({{ name }} >= {{ bound }}) {
|
| 7 |
return;
|
| 8 |
-
}
|
|
|
|
| 9 |
{{ env.wgsl.resourceDeclarations }}
|
| 10 |
{% set wg = workgroupSize if workgroupSize is defined else tunables.WORKGROUP_SIZE %}
|
| 11 |
|
| 12 |
// Computes GELU, optionally after adding a rank-1 bias broadcast over the
|
| 13 |
// innermost axis. A present bias uses element_index % hidden_extent. The `vec4`
|
| 14 |
-
// path requires the
|
| 15 |
-
//
|
|
|
|
| 16 |
// GELU uses the rational erf approximation defined below.
|
| 17 |
fn erf_approx(x: f32) -> f32 {
|
| 18 |
let ax = abs(x);
|
|
@@ -37,9 +39,13 @@ fn gelu_value(v: f32) -> f32 {
|
|
| 37 |
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
| 38 |
{{ flat_index_2d(wg) }}
|
| 39 |
{% if vec4 %}
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
let v = xv;
|
| 42 |
-
y[
|
|
|
|
| 43 |
{% else %}
|
| 44 |
let xv = f32(x[i]);
|
| 45 |
let v = xv;
|
|
|
|
| 1 |
+
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count") %}
|
| 2 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 3 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 4 |
// per-axis workgroup fold width.
|
| 5 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 6 |
if ({{ name }} >= {{ bound }}) {
|
| 7 |
return;
|
| 8 |
+
}
|
| 9 |
+
{% endmacro %}
|
| 10 |
{{ env.wgsl.resourceDeclarations }}
|
| 11 |
{% set wg = workgroupSize if workgroupSize is defined else tunables.WORKGROUP_SIZE %}
|
| 12 |
|
| 13 |
// Computes GELU, optionally after adding a rank-1 bias broadcast over the
|
| 14 |
// innermost axis. A present bias uses element_index % hidden_extent. The `vec4`
|
| 15 |
+
// path requires the element count to be divisible by four and may wrap bias
|
| 16 |
+
// indices across rows. A complete small bias period can cover several vector
|
| 17 |
+
// words per invocation; `vec4Tail` uses scalar bindings with guarded lanes.
|
| 18 |
// GELU uses the rational erf approximation defined below.
|
| 19 |
fn erf_approx(x: f32) -> f32 {
|
| 20 |
let ax = abs(x);
|
|
|
|
| 39 |
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
| 40 |
{{ flat_index_2d(wg) }}
|
| 41 |
{% if vec4 %}
|
| 42 |
+
{% set blocks = 1 %}
|
| 43 |
+
{% for block in range(blocks) %}
|
| 44 |
+
{% set idx = 'i' %}
|
| 45 |
+
let xv = vec4<f32>(x[{{ idx }}]);
|
| 46 |
let v = xv;
|
| 47 |
+
y[{{ idx }}] = vec4<{{ scalar }}>(vec4<f32>(gelu_value(v.x), gelu_value(v.y), gelu_value(v.z), gelu_value(v.w)));
|
| 48 |
+
{% endfor %}
|
| 49 |
{% else %}
|
| 50 |
let xv = f32(x[i]);
|
| 51 |
let v = xv;
|
build/webgpu/manifest.json
CHANGED
|
@@ -1,58 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"domain": "com.microsoft",
|
| 3 |
-
"name": "Gelu",
|
| 4 |
-
"sinceVersion": 1,
|
| 5 |
-
"inputs": { "X": { "dtype": "T" } },
|
| 6 |
-
"outputs": { "Y": { "dtype": "T", "rank": "ranks.X", "shape": "shapes.X" } },
|
| 7 |
-
"typeConstraints": { "T": ["float32", "float16"] },
|
| 8 |
-
"tunables": { "WORKGROUP_SIZE": { "default": 256 } },
|
| 9 |
-
"derive": { "scalar": "dtypes.T", "vec4Tail": false },
|
| 10 |
-
"when": ["numel(shapes.X) == numel(shapes.Y)", "f16Ok(dtypes.T)"],
|
| 11 |
-
"variants": [
|
| 12 |
-
{
|
| 13 |
-
"id": "vec4",
|
| 14 |
-
"priority": 20,
|
| 15 |
-
"when": ["numel(shapes.X) > 0", "numel(shapes.X) % 4 == 0"],
|
| 16 |
-
"derive": { "vec4": true, "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" },
|
| 17 |
-
"passes": [
|
| 18 |
-
{
|
| 19 |
-
"id": "main",
|
| 20 |
-
"name": "Gelu.Vec4",
|
| 21 |
-
"shader": "elementwise-bias-gelu.wgsl.jinja",
|
| 22 |
-
"bindings": [
|
| 23 |
-
{ "arg": "X", "name": "x", "elementType": "$vectorScalar" },
|
| 24 |
-
{ "arg": "Y", "name": "y", "elementType": "$vectorScalar" },
|
| 25 |
-
{ "name": "params", "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.X) / 4" }] }
|
| 26 |
-
],
|
| 27 |
-
"dispatch": {
|
| 28 |
-
"x": "min(ceilDiv((numel(shapes.X) / 4), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 29 |
-
"y": "ceilDiv(ceilDiv((numel(shapes.X) / 4), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 30 |
-
"z": 1
|
| 31 |
-
}
|
| 32 |
-
}
|
| 33 |
-
]
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"id": "scalar",
|
| 37 |
-
"priority": 0,
|
| 38 |
-
"derive": { "vec4": false },
|
| 39 |
-
"passes": [
|
| 40 |
-
{
|
| 41 |
-
"id": "main",
|
| 42 |
-
"name": "Gelu.Scalar",
|
| 43 |
-
"shader": "elementwise-bias-gelu.wgsl.jinja",
|
| 44 |
-
"bindings": [
|
| 45 |
-
{ "arg": "X", "name": "x", "elementType": "$scalar" },
|
| 46 |
-
{ "arg": "Y", "name": "y", "elementType": "$scalar" },
|
| 47 |
-
{ "name": "params", "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.X)" }] }
|
| 48 |
-
],
|
| 49 |
-
"dispatch": {
|
| 50 |
-
"x": "min(ceilDiv((numel(shapes.X)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 51 |
-
"y": "ceilDiv(ceilDiv((numel(shapes.X)), (tunables.WORKGROUP_SIZE)), 65535)",
|
| 52 |
-
"z": 1
|
| 53 |
-
}
|
| 54 |
-
}
|
| 55 |
-
]
|
| 56 |
-
}
|
| 57 |
-
]
|
| 58 |
-
}
|
|
|
|
| 1 |
+
{"domain":"com.microsoft","name":"Gelu","sinceVersion":1,"inputs":{"X":{"dtype":"T"}},"outputs":{"Y":{"dtype":"T","rank":"ranks.X","shape":"shapes.X"}},"typeConstraints":{"T":["float32","float16"]},"tunables":{"WORKGROUP_SIZE":{"default":256}},"derive":{"scalar":"dtypes.T","vec4Tail":false},"when":["numel(shapes.X) == numel(shapes.Y)","f16Ok(dtypes.T)"],"variants":[{"id":"vec4","priority":20,"when":["numel(shapes.X) > 0","numel(shapes.X) % 4 == 0"],"derive":{"vec4":true,"vectorScalar":"\"vec4<\" ~ dtypes.T ~ \">\""},"passes":[{"id":"main","name":"Gelu.Vec4","shader":"elementwise-bias-gelu.wgsl.jinja","bindings":[{"arg":"X","name":"x","elementType":"$vectorScalar"},{"arg":"Y","name":"y","elementType":"$vectorScalar"},{"name":"params","struct":[{"name":"count","type":"u32","value":"numel(shapes.X) / 4"}]}],"dispatch":{"x":"min(ceilDiv((numel(shapes.X) / 4), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((numel(shapes.X) / 4), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]},{"id":"scalar","priority":0,"derive":{"vec4":false},"passes":[{"id":"main","name":"Gelu.Scalar","shader":"elementwise-bias-gelu.wgsl.jinja","bindings":[{"arg":"X","name":"x","elementType":"$scalar"},{"arg":"Y","name":"y","elementType":"$scalar"},{"name":"params","struct":[{"name":"count","type":"u32","value":"numel(shapes.X)"}]}],"dispatch":{"x":"min(ceilDiv((numel(shapes.X)), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((numel(shapes.X)), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/webgpu/metadata.json
CHANGED
|
@@ -1,21 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "com.microsoft.Gelu",
|
| 3 |
-
"id": "_com_microsoft_gelu_webgpu_7e75dcc",
|
| 4 |
-
"version": 1,
|
| 5 |
-
"license": "Apache-2.0",
|
| 6 |
-
"backend": { "type": "webgpu" },
|
| 7 |
-
"digest": {
|
| 8 |
-
"algorithm": "sha256",
|
| 9 |
-
"files": {
|
| 10 |
-
"bench.json": "zb+BUPCMklZQithfY94RzWttjR/SZK0PIWgZjexuaxs=",
|
| 11 |
-
"elementwise-bias-gelu.wgsl.jinja": "BDGBTzz/SKEd8tbwt6VCzjky2+w28H9UZ6WSGEbeZSQ=",
|
| 12 |
-
"manifest.json": "Vx/CPPXNBVsauc5qnG9IeRU55D0gQVbGJtk/S40peXg=",
|
| 13 |
-
"test.json": "K4VvkDT8J9wTZh+uYL3GSIAzvOw0PuV04RAIyhxmgxM="
|
| 14 |
-
}
|
| 15 |
-
},
|
| 16 |
-
"provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } },
|
| 17 |
-
"webgpu": {
|
| 18 |
-
"manifestSpec": "2.1",
|
| 19 |
-
"variants": { "vec4": ["elementwise-bias-gelu.wgsl.jinja"], "scalar": ["elementwise-bias-gelu.wgsl.jinja"] }
|
| 20 |
-
}
|
| 21 |
-
}
|
|
|
|
| 1 |
+
{"name":"com.microsoft.Gelu","id":"_com_microsoft_gelu_webgpu_408f83a","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"zb+BUPCMklZQithfY94RzWttjR/SZK0PIWgZjexuaxs=","elementwise-bias-gelu.wgsl.jinja":"0jbHuFrhaqE/rgtkqt11FLYum0b0MB23hqJcUCSVods=","manifest.json":"QkBzpwA3I4brTMfTgJvUTGiEtQIz/SSeoEFXyuEtA5o=","test.json":"43wjyrbEVnFtfZ+d4woLAVDsV5daEHEafEWIzkGiOmc="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/webgpu/test.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
| 38 |
"provenance": {
|
| 39 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 40 |
"test": "ActivationOpTest.Gelu_bfloat16",
|
| 41 |
-
"notes": "Float32
|
| 42 |
},
|
| 43 |
"inputs": {
|
| 44 |
"X": {
|
|
@@ -69,12 +69,12 @@
|
|
| 69 |
"name": "f32_subnormal_linear_region_vec4_gpu_gap",
|
| 70 |
"skipGpu": {
|
| 71 |
"category": "permanent",
|
| 72 |
-
"reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture.
|
| 73 |
},
|
| 74 |
"provenance": {
|
| 75 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 76 |
"test": "ActivationOpTest.Gelu",
|
| 77 |
-
"notes": "Near zero, exact erf-form GELU is approximately x/2
|
| 78 |
},
|
| 79 |
"inputs": {
|
| 80 |
"X": {
|
|
@@ -99,12 +99,12 @@
|
|
| 99 |
"name": "f32_subnormal_linear_region_scalar_gpu_gap",
|
| 100 |
"skipGpu": {
|
| 101 |
"category": "permanent",
|
| 102 |
-
"reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture.
|
| 103 |
},
|
| 104 |
"provenance": {
|
| 105 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 106 |
"test": "ActivationOpTest.Gelu",
|
| 107 |
-
"notes": "
|
| 108 |
},
|
| 109 |
"inputs": {
|
| 110 |
"X": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1e-40, -1e-40, 1e-38] } }
|
|
@@ -123,7 +123,7 @@
|
|
| 123 |
"provenance": {
|
| 124 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 125 |
"test": "ActivationOpTest.Gelu",
|
| 126 |
-
"notes": "
|
| 127 |
},
|
| 128 |
"inputs": { "X": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [-0.5] } } },
|
| 129 |
"outputs": {
|
|
@@ -198,6 +198,112 @@
|
|
| 198 |
}
|
| 199 |
}
|
| 200 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
}
|
| 202 |
]
|
| 203 |
}
|
|
|
|
| 38 |
"provenance": {
|
| 39 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 40 |
"test": "ActivationOpTest.Gelu_bfloat16",
|
| 41 |
+
"notes": "Float32 version of the nonfinite-input case; -Infinity produces NaN under the exact erf expression."
|
| 42 |
},
|
| 43 |
"inputs": {
|
| 44 |
"X": {
|
|
|
|
| 69 |
"name": "f32_subnormal_linear_region_vec4_gpu_gap",
|
| 70 |
"skipGpu": {
|
| 71 |
"category": "permanent",
|
| 72 |
+
"reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Metal flushes float32 and float16 subnormal inputs and outputs to zero."
|
| 73 |
},
|
| 74 |
"provenance": {
|
| 75 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 76 |
"test": "ActivationOpTest.Gelu",
|
| 77 |
+
"notes": "Near zero, exact erf-form GELU is approximately x/2, so the four subnormal inputs give finite subnormal outputs."
|
| 78 |
},
|
| 79 |
"inputs": {
|
| 80 |
"X": {
|
|
|
|
| 99 |
"name": "f32_subnormal_linear_region_scalar_gpu_gap",
|
| 100 |
"skipGpu": {
|
| 101 |
"category": "permanent",
|
| 102 |
+
"reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Metal flushes float32 and float16 subnormal inputs and outputs to zero."
|
| 103 |
},
|
| 104 |
"provenance": {
|
| 105 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 106 |
"test": "ActivationOpTest.Gelu",
|
| 107 |
+
"notes": "Three subnormal inputs exercise the linear region of the exact GELU."
|
| 108 |
},
|
| 109 |
"inputs": {
|
| 110 |
"X": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1e-40, -1e-40, 1e-38] } }
|
|
|
|
| 123 |
"provenance": {
|
| 124 |
"source": "onnxruntime/test/contrib_ops/activation_op_test.cc",
|
| 125 |
"test": "ActivationOpTest.Gelu",
|
| 126 |
+
"notes": "A rank-0 (scalar) negative input uses the same exact erf-form GELU."
|
| 127 |
},
|
| 128 |
"inputs": { "X": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [-0.5] } } },
|
| 129 |
"outputs": {
|
|
|
|
| 198 |
}
|
| 199 |
}
|
| 200 |
}
|
| 201 |
+
},
|
| 202 |
+
{
|
| 203 |
+
"name": "ort_regression_f16_extreme_finite_none_vec4",
|
| 204 |
+
"provenance": {
|
| 205 |
+
"source": "onnxruntime/core/mlas/lib/gelu_neon_fp16.cpp and erf_neon_fp16.cpp",
|
| 206 |
+
"notes": "Four rotations place both signs of maximum finite f16 and the 32768 overflow boundary in every vector lane; the 17th scalar element repeats 65504. Independent scalar math expectations stay finite."
|
| 207 |
+
},
|
| 208 |
+
"attrs": {},
|
| 209 |
+
"inputs": {
|
| 210 |
+
"X": {
|
| 211 |
+
"dtype": "float16",
|
| 212 |
+
"shape": [16],
|
| 213 |
+
"data": {
|
| 214 |
+
"kind": "values",
|
| 215 |
+
"values": [65504.0, -65504.0, 32768.0, -32768.0, -65504.0, 32768.0, -32768.0, 65504.0, 32768.0, -32768.0, 65504.0, -65504.0, -32768.0, 65504.0, -65504.0, 32768.0]
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
},
|
| 219 |
+
"outputs": {
|
| 220 |
+
"Y": {
|
| 221 |
+
"dtype": "float16",
|
| 222 |
+
"shape": [16],
|
| 223 |
+
"data": {
|
| 224 |
+
"kind": "values",
|
| 225 |
+
"values": [65504.0, -0.0, 32768.0, -0.0, -0.0, 32768.0, -0.0, 65504.0, 32768.0, -0.0, 65504.0, -0.0, -0.0, 65504.0, -0.0, 32768.0]
|
| 226 |
+
},
|
| 227 |
+
"tolerance": 0
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"name": "ort_regression_f16_extreme_finite_none_scalar_tail",
|
| 233 |
+
"provenance": {
|
| 234 |
+
"source": "onnxruntime/core/mlas/lib/gelu_neon_fp16.cpp and erf_neon_fp16.cpp",
|
| 235 |
+
"notes": "Four rotations place both signs of maximum finite f16 and the 32768 overflow boundary in every vector lane; the 17th scalar element repeats 65504. Independent scalar math expectations stay finite."
|
| 236 |
+
},
|
| 237 |
+
"attrs": {},
|
| 238 |
+
"inputs": {
|
| 239 |
+
"X": {
|
| 240 |
+
"dtype": "float16",
|
| 241 |
+
"shape": [17],
|
| 242 |
+
"data": {
|
| 243 |
+
"kind": "values",
|
| 244 |
+
"values": [65504.0, -65504.0, 32768.0, -32768.0, -65504.0, 32768.0, -32768.0, 65504.0, 32768.0, -32768.0, 65504.0, -65504.0, -32768.0, 65504.0, -65504.0, 32768.0, 65504.0]
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
},
|
| 248 |
+
"outputs": {
|
| 249 |
+
"Y": {
|
| 250 |
+
"dtype": "float16",
|
| 251 |
+
"shape": [17],
|
| 252 |
+
"data": {
|
| 253 |
+
"kind": "values",
|
| 254 |
+
"values": [65504.0, -0.0, 32768.0, -0.0, -0.0, 32768.0, -0.0, 65504.0, 32768.0, -0.0, 65504.0, -0.0, -0.0, 65504.0, -0.0, 32768.0, 65504.0]
|
| 255 |
+
},
|
| 256 |
+
"tolerance": 0
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
},
|
| 260 |
+
{
|
| 261 |
+
"name": "ort_regression_f16_nonfinite_vec4",
|
| 262 |
+
"provenance": {
|
| 263 |
+
"source": "Inf/NaN cases following onnxruntime/core/mlas/lib/gelu_neon_fp16.cpp and erf_neon_fp16.cpp",
|
| 264 |
+
"notes": "In float16 storage, NaN propagates, GELU(+Inf)=+Inf and the IEEE formula gives GELU(-Inf)=NaN. Input infinities are produced by half conversion of finite JSON numbers."
|
| 265 |
+
},
|
| 266 |
+
"attrs": {},
|
| 267 |
+
"inputs": {
|
| 268 |
+
"X": {
|
| 269 |
+
"dtype": "float16",
|
| 270 |
+
"shape": [4],
|
| 271 |
+
"data": { "kind": "values", "values": [0.0, -1e+39, 1e+39, 0.0], "nanStart": 0.0, "nanCount": 1.0 }
|
| 272 |
+
}
|
| 273 |
+
},
|
| 274 |
+
"outputs": {
|
| 275 |
+
"Y": {
|
| 276 |
+
"dtype": "float16",
|
| 277 |
+
"shape": [4],
|
| 278 |
+
"tolerance": 0,
|
| 279 |
+
"allowNaN": true,
|
| 280 |
+
"data": { "kind": "values", "values": [0.0, 0.0, 1e+39, 0.0], "nanStart": 0.0, "nanCount": 2.0 }
|
| 281 |
+
}
|
| 282 |
+
}
|
| 283 |
+
},
|
| 284 |
+
{
|
| 285 |
+
"name": "ort_regression_f16_nonfinite_scalar_tail",
|
| 286 |
+
"provenance": {
|
| 287 |
+
"source": "Inf/NaN cases following onnxruntime/core/mlas/lib/gelu_neon_fp16.cpp and erf_neon_fp16.cpp",
|
| 288 |
+
"notes": "In float16 storage, NaN propagates, GELU(+Inf)=+Inf and the IEEE formula gives GELU(-Inf)=NaN. A fifth element, the maximum finite half 65504, stays 65504, separating large finite inputs from nonfinite handling. Input infinities are produced by half conversion of finite JSON numbers."
|
| 289 |
+
},
|
| 290 |
+
"attrs": {},
|
| 291 |
+
"inputs": {
|
| 292 |
+
"X": {
|
| 293 |
+
"dtype": "float16",
|
| 294 |
+
"shape": [5],
|
| 295 |
+
"data": { "kind": "values", "values": [0.0, -1e+39, 1e+39, 0.0, 65504.0], "nanStart": 0.0, "nanCount": 1.0 }
|
| 296 |
+
}
|
| 297 |
+
},
|
| 298 |
+
"outputs": {
|
| 299 |
+
"Y": {
|
| 300 |
+
"dtype": "float16",
|
| 301 |
+
"shape": [5],
|
| 302 |
+
"tolerance": 0,
|
| 303 |
+
"allowNaN": true,
|
| 304 |
+
"data": { "kind": "values", "values": [0.0, 0.0, 1e+39, 0.0, 65504.0], "nanStart": 0.0, "nanCount": 2.0 }
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
}
|
| 308 |
]
|
| 309 |
}
|