sync 2e7068faf55e
Browse files- README.md +60 -0
- build/webgpu/bench.json +73 -0
- build/webgpu/bias-split-gelu.wgsl.jinja +116 -0
- build/webgpu/manifest.json +194 -0
- build/webgpu/metadata.json +18 -0
- build/webgpu/test.json +266 -0
README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: kernels
|
| 3 |
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- kernel
|
| 6 |
+
- webgpu
|
| 7 |
+
- wgsl
|
| 8 |
---
|
| 9 |
+
# com.microsoft.BiasSplitGelu
|
| 10 |
+
|
| 11 |
+
`com.microsoft` · ONNX Runtime contrib operator · contrib since_version 1
|
| 12 |
+
|
| 13 |
+
## Description
|
| 14 |
+
|
| 15 |
+
Adds `bias` to `X`, splits the last dimension in half, then multiplies the left half elementwise by the GELU activation of the right half, producing an output with half the hidden dimension. Used as a fused activation in diffusion models.
|
| 16 |
+
|
| 17 |
+
See the [ONNX Runtime `BiasSplitGelu` contrib-operator spec](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.BiasSplitGelu) for the reference semantics.
|
| 18 |
+
|
| 19 |
+
## Inputs
|
| 20 |
+
|
| 21 |
+
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|
| 22 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 23 |
+
| `X` | `X` | `T` | `3` | — | Input tensor of shape `(N, S, D)`, where `N` is the batch size, `S` is the spatial size, and `D` is the hidden dimension. | required |
|
| 24 |
+
| `bias` | `bias` | `T` | `1` | — | 1-D bias tensor of length D, matching the hidden dimension of X. | required |
|
| 25 |
+
|
| 26 |
+
## Outputs
|
| 27 |
+
|
| 28 |
+
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|
| 29 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 30 |
+
| `Y` | `Y` | `T` | `3` | derived; see description | Output tensor of shape `(N, S, D/2)` after the split-GELU activation. | required |
|
| 31 |
+
|
| 32 |
+
## Type constraints
|
| 33 |
+
|
| 34 |
+
| Variable | Allowed dtypes |
|
| 35 |
+
| --- | --- |
|
| 36 |
+
| `T` | `float32`, `float16` |
|
| 37 |
+
|
| 38 |
+
## Files
|
| 39 |
+
|
| 40 |
+
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, provenance)
|
| 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 + tuning cases
|
| 44 |
+
- [`bias-split-gelu.wgsl.jinja`](build/webgpu/bias-split-gelu.wgsl.jinja)
|
| 45 |
+
|
| 46 |
+
## Use with `@huggingface/kernels`
|
| 47 |
+
|
| 48 |
+
The loader derives every required output's shape and logical dtype from the manifest contract and this call.
|
| 49 |
+
It then allocates the result tensors automatically.
|
| 50 |
+
|
| 51 |
+
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 52 |
+
|
| 53 |
+
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
|
| 54 |
+
|
| 55 |
+
```js
|
| 56 |
+
import { getKernel } from "@huggingface/kernels";
|
| 57 |
+
|
| 58 |
+
const kernel = await getKernel("webgpu-kernels/com.microsoft.BiasSplitGelu", { version: 1 });
|
| 59 |
+
const { Y } = await kernel({
|
| 60 |
+
X: { data: XData, shape: [1, 2, 4] },
|
| 61 |
+
bias: { data: biasData, shape: [4] },
|
| 62 |
+
});
|
| 63 |
+
```
|
build/webgpu/bench.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"op": "com.microsoft.BiasSplitGelu",
|
| 3 |
+
"tunableSpace": { "WORKGROUP_SIZE": [64, 128, 256] },
|
| 4 |
+
"cases": [
|
| 5 |
+
{
|
| 6 |
+
"name": "biassplitgelu-f32-4096x5120",
|
| 7 |
+
"preset": "smoke",
|
| 8 |
+
"vars": { "dtype": "float32" },
|
| 9 |
+
"inputs": {
|
| 10 |
+
"X": { "shape": [1, 4096, 5120], "dtype": "float32", "dist": "normal", "seed": 610, "scale": 2 },
|
| 11 |
+
"bias": { "shape": [5120], "dtype": "float32", "dist": "normal", "seed": 611, "scale": 1 }
|
| 12 |
+
},
|
| 13 |
+
"outputs": { "Y": { "shape": [1, 4096, 2560], "dtype": "float32" } },
|
| 14 |
+
"bench": {
|
| 15 |
+
"metrics": [
|
| 16 |
+
{
|
| 17 |
+
"type": "bandwidth",
|
| 18 |
+
"value": "4096 * 5120 * dtypeBytes(args.dtype) + 4096 * 2560 * dtypeBytes(args.dtype)"
|
| 19 |
+
}
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"name": "biassplitgelu-f16-4096x5120",
|
| 25 |
+
"preset": "model",
|
| 26 |
+
"vars": { "dtype": "float16" },
|
| 27 |
+
"inputs": {
|
| 28 |
+
"X": { "shape": [1, 4096, 5120], "dtype": "float16", "dist": "normal", "seed": 612, "scale": 2 },
|
| 29 |
+
"bias": { "shape": [5120], "dtype": "float16", "dist": "normal", "seed": 613, "scale": 1 }
|
| 30 |
+
},
|
| 31 |
+
"outputs": { "Y": { "shape": [1, 4096, 2560], "dtype": "float16" } },
|
| 32 |
+
"bench": {
|
| 33 |
+
"metrics": [
|
| 34 |
+
{
|
| 35 |
+
"type": "bandwidth",
|
| 36 |
+
"value": "4096 * 5120 * dtypeBytes(args.dtype) + 4096 * 2560 * dtypeBytes(args.dtype)"
|
| 37 |
+
}
|
| 38 |
+
]
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"name": "biassplitgelu-f16-compact-vec4-validation-gap",
|
| 43 |
+
"preset": "edge",
|
| 44 |
+
"vars": { "dtype": "float16" },
|
| 45 |
+
"inputs": {
|
| 46 |
+
"X": { "shape": [1, 1, 8], "dtype": "float16", "dist": "normal", "seed": 614, "scale": 2 },
|
| 47 |
+
"bias": { "shape": [8], "dtype": "float16", "dist": "normal", "seed": 615, "scale": 1 }
|
| 48 |
+
},
|
| 49 |
+
"outputs": { "Y": { "shape": [1, 1, 4], "dtype": "float16" } },
|
| 50 |
+
"bench": {
|
| 51 |
+
"metrics": [{ "type": "bandwidth", "value": "8 * dtypeBytes(args.dtype) + 4 * dtypeBytes(args.dtype)" }]
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "biassplitgelu-f32-scalar-cliff-4096x5116",
|
| 56 |
+
"preset": "stress",
|
| 57 |
+
"vars": { "dtype": "float32" },
|
| 58 |
+
"inputs": {
|
| 59 |
+
"X": { "shape": [1, 4096, 5116], "dtype": "float32", "dist": "normal", "seed": 620, "scale": 2 },
|
| 60 |
+
"bias": { "shape": [5116], "dtype": "float32", "dist": "normal", "seed": 621, "scale": 1 }
|
| 61 |
+
},
|
| 62 |
+
"outputs": { "Y": { "shape": [1, 4096, 2558], "dtype": "float32" } },
|
| 63 |
+
"bench": {
|
| 64 |
+
"metrics": [
|
| 65 |
+
{
|
| 66 |
+
"type": "bandwidth",
|
| 67 |
+
"value": "4096 * 5116 * dtypeBytes(args.dtype) + 4096 * 2558 * dtypeBytes(args.dtype)"
|
| 68 |
+
}
|
| 69 |
+
]
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
]
|
| 73 |
+
}
|
build/webgpu/bias-split-gelu.wgsl.jinja
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}
|
| 2 |
+
{% if note == "dispatch-limit" %}
|
| 3 |
+
// 2D-folded flat index: gid.y carries the high bits past the
|
| 4 |
+
// maxComputeWorkgroupsPerDimension dispatch limit (outputs > 16.7M elements).
|
| 5 |
+
{% elif note == "limit" %}
|
| 6 |
+
// 2D-folded flat index: gid.y carries the high bits past the
|
| 7 |
+
// maxComputeWorkgroupsPerDimension limit.
|
| 8 |
+
{% elif note == "device-axis" %}
|
| 9 |
+
// The flat dispatch is folded across x/y at the device's per-axis workgroup
|
| 10 |
+
// limit; gid.y carries the high portion of the output index.
|
| 11 |
+
{% elif note == "vec4-limit" %}
|
| 12 |
+
// 2D-folded flat vec4 index: gid.y carries the high bits past the
|
| 13 |
+
// maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills into y).
|
| 14 |
+
{% elif note == "element-limit" %}
|
| 15 |
+
// 2D-folded flat element index: gid.y carries the high bits past the
|
| 16 |
+
// maxComputeWorkgroupsPerDimension limit.
|
| 17 |
+
{% elif note == "dispatch" %}
|
| 18 |
+
// 2D-folded flat index: gid.y carries the high bits past the
|
| 19 |
+
// maxComputeWorkgroupsPerDimension dispatch limit.
|
| 20 |
+
{% endif %}
|
| 21 |
+
{% if bound == "" %}
|
| 22 |
+
let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
|
| 23 |
+
{%- elif guardInline %}
|
| 24 |
+
let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
|
| 25 |
+
if ({{ name }} >= {{ bound }}) { return; }
|
| 26 |
+
{%- else %}
|
| 27 |
+
let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
|
| 28 |
+
if ({{ name }} >= {{ bound }}) {
|
| 29 |
+
return;
|
| 30 |
+
}
|
| 31 |
+
{%- endif %}
|
| 32 |
+
{% endmacro %}
|
| 33 |
+
|
| 34 |
+
{% if usesF16 %}
|
| 35 |
+
enable f16;
|
| 36 |
+
{% endif %}
|
| 37 |
+
{{ env.wgsl.resourceDeclarations }}
|
| 38 |
+
|
| 39 |
+
// com.microsoft.BiasSplitGelu GEGLU gate:
|
| 40 |
+
// The innermost (hidden) axis of (X + bias) has size 2*D. Split it into
|
| 41 |
+
// value = [.., 0:D] and gate = [.., D:2D], then
|
| 42 |
+
// Y[.., d] = value[.., d] * gelu_erf(gate[.., d])
|
| 43 |
+
// gelu_erf(g) = 0.5 * g * (1 + erf(g / sqrt2)).
|
| 44 |
+
// bias is a rank-1 vector [2*D] broadcast over the hidden axis. The output
|
| 45 |
+
// hidden axis is D (= HIDDEN below); the input hidden axis is 2*D (TWICE).
|
| 46 |
+
// erf_approx uses an overflow-safe rational approximation.
|
| 47 |
+
fn erf_approx(x: f32) -> f32 {
|
| 48 |
+
let ax = abs(x);
|
| 49 |
+
// The polynomial has a small nonzero floor near zero. Use erf(x) ~=
|
| 50 |
+
// 2/sqrt(pi)*x below 2^-20 to preserve erf(0) == 0, odd symmetry, and the
|
| 51 |
+
// correctly rounded f32 result. The exactly representable threshold keeps
|
| 52 |
+
// scalar and vector branching identical. NaN falls through to the polynomial
|
| 53 |
+
// and propagates.
|
| 54 |
+
if (ax < 9.5367431640625e-7) {
|
| 55 |
+
return 1.1283791670955126 * x;
|
| 56 |
+
}
|
| 57 |
+
let sign = select(-1.0, 1.0, x >= 0.0);
|
| 58 |
+
let t = 1.0 / (1.0 + 0.3275911 * ax);
|
| 59 |
+
let y = 1.0 - (((((1.061405429 * t - 1.453152027) * t) + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * exp(-(ax * ax));
|
| 60 |
+
return sign * y;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
fn gelu_value(v: f32) -> f32 {
|
| 64 |
+
return 0.5 * v * (1.0 + erf_approx(v * 0.7071067811865476));
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
const HIDDEN: u32 = {{ hidden }}u; // D: output hidden axis
|
| 68 |
+
const TWICE: u32 = {{ twice }}u; // 2*D: input hidden axis
|
| 69 |
+
{% if vec4Tail %}
|
| 70 |
+
const GROUPS_PER_ROW: u32 = (HIDDEN + 3u) / 4u;
|
| 71 |
+
|
| 72 |
+
{% endif %}
|
| 73 |
+
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
|
| 74 |
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
|
| 75 |
+
{{ flat_index_2d() }}
|
| 76 |
+
{% if vec4Tail %}
|
| 77 |
+
let row = i / GROUPS_PER_ROW;
|
| 78 |
+
let col = (i % GROUPS_PER_ROW) * 4u;
|
| 79 |
+
{% for lane in range(4) %}
|
| 80 |
+
if (col + {{ lane }}u < HIDDEN) {
|
| 81 |
+
let vidx{{ lane }} = row * TWICE + col + {{ lane }}u;
|
| 82 |
+
let gidx{{ lane }} = vidx{{ lane }} + HIDDEN;
|
| 83 |
+
let val{{ lane }} = f32(x[vidx{{ lane }}]) + f32(bias[col + {{ lane }}u]);
|
| 84 |
+
let gate{{ lane }} = f32(x[gidx{{ lane }}]) + f32(bias[col + HIDDEN + {{ lane }}u]);
|
| 85 |
+
y[row * HIDDEN + col + {{ lane }}u] = {{ scalar }}(val{{ lane }} * gelu_value(gate{{ lane }}));
|
| 86 |
+
}
|
| 87 |
+
{% endfor %}
|
| 88 |
+
{% elif vec4 %}
|
| 89 |
+
// Each output vec4 covers 4 consecutive elements within one row of the D
|
| 90 |
+
// axis (D % 4 == 0 guarantees the group never crosses the hidden boundary).
|
| 91 |
+
let base = i * 4u;
|
| 92 |
+
let row = base / HIDDEN;
|
| 93 |
+
let col = base % HIDDEN;
|
| 94 |
+
let vbase = row * TWICE + col; // value half: [row, col .. col+3]
|
| 95 |
+
let gbase = vbase + HIDDEN; // gate half: [row, D+col .. D+col+3]
|
| 96 |
+
// f32(...) each lane: X may be f16 storage, and WGSL has no implicit f16->f32
|
| 97 |
+
// conversion inside a vec4<f32> constructor (it is a no-op when X is f32).
|
| 98 |
+
let valv = vec4<f32>(f32(x[vbase]), f32(x[vbase + 1u]), f32(x[vbase + 2u]), f32(x[vbase + 3u]))
|
| 99 |
+
+ vec4<f32>(f32(bias[col]), f32(bias[col + 1u]), f32(bias[col + 2u]), f32(bias[col + 3u]));
|
| 100 |
+
let gatev = vec4<f32>(f32(x[gbase]), f32(x[gbase + 1u]), f32(x[gbase + 2u]), f32(x[gbase + 3u]))
|
| 101 |
+
+ vec4<f32>(f32(bias[col + HIDDEN]), f32(bias[col + HIDDEN + 1u]), f32(bias[col + HIDDEN + 2u]), f32(bias[col + HIDDEN + 3u]));
|
| 102 |
+
y[i] = vec4<{{ scalar }}>(vec4<f32>(
|
| 103 |
+
valv.x * gelu_value(gatev.x),
|
| 104 |
+
valv.y * gelu_value(gatev.y),
|
| 105 |
+
valv.z * gelu_value(gatev.z),
|
| 106 |
+
valv.w * gelu_value(gatev.w)));
|
| 107 |
+
{% else %}
|
| 108 |
+
let row = i / HIDDEN;
|
| 109 |
+
let col = i % HIDDEN;
|
| 110 |
+
let vidx = row * TWICE + col; // value element
|
| 111 |
+
let gidx = vidx + HIDDEN; // gate element
|
| 112 |
+
let val = f32(x[vidx]) + f32(bias[col]);
|
| 113 |
+
let gate = f32(x[gidx]) + f32(bias[col + HIDDEN]);
|
| 114 |
+
y[i] = {{ scalar }}(val * gelu_value(gate));
|
| 115 |
+
{% endif %}
|
| 116 |
+
}
|
build/webgpu/manifest.json
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"domain": "com.microsoft",
|
| 3 |
+
"name": "BiasSplitGelu",
|
| 4 |
+
"sinceVersion": 1,
|
| 5 |
+
"description": "Adds `bias` to `X`, splits the last dimension in half, then multiplies the left half elementwise by the GELU activation of the right half, producing an output with half the hidden dimension. Used as a fused activation in diffusion models.",
|
| 6 |
+
"inputs": [
|
| 7 |
+
{
|
| 8 |
+
"role": "X",
|
| 9 |
+
"dtype": "T",
|
| 10 |
+
"rank": 3,
|
| 11 |
+
"description": "Input tensor of shape `(N, S, D)`, where `N` is the batch size, `S` is the spatial size, and `D` is the hidden dimension."
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"role": "bias",
|
| 15 |
+
"dtype": "T",
|
| 16 |
+
"rank": 1,
|
| 17 |
+
"description": "1-D bias tensor of length D, matching the hidden dimension of X."
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"outputs": [
|
| 21 |
+
{
|
| 22 |
+
"role": "Y",
|
| 23 |
+
"dtype": "T",
|
| 24 |
+
"rank": 3,
|
| 25 |
+
"shape": "[dim(shapes.X, 0), dim(shapes.X, 1), dim(shapes.X, 2) / 2]",
|
| 26 |
+
"description": "Output tensor of shape `(N, S, D/2)` after the split-GELU activation."
|
| 27 |
+
}
|
| 28 |
+
],
|
| 29 |
+
"typeConstraints": { "T": ["float32", "float16"] },
|
| 30 |
+
"args": {
|
| 31 |
+
"X": { "kind": "tensor", "semantic": "X", "role": "input" },
|
| 32 |
+
"bias": { "kind": "tensor", "semantic": "bias", "role": "input" },
|
| 33 |
+
"Y": { "kind": "tensor", "semantic": "Y", "role": "output" }
|
| 34 |
+
},
|
| 35 |
+
"tunables": { "WORKGROUP_SIZE": 64 },
|
| 36 |
+
"variants": [
|
| 37 |
+
{
|
| 38 |
+
"id": "vec4",
|
| 39 |
+
"priority": 30,
|
| 40 |
+
"when": ["ranks.X == 3", "ranks.Y == 3", "dim(shapes.Y, 0) == dim(shapes.X, 0)", "dim(shapes.Y, 1) == dim(shapes.X, 1)", "dim(shapes.X, 2) % 2 == 0", "dim(shapes.Y, 2) == dim(shapes.X, 2) / 2", "f16Ok(dtypes.T)", "ranks.bias == 1", "dim(shapes.bias, 0) == dim(shapes.X, 2)", "numel(shapes.Y) > 0", "numel(shapes.Y) % 4 == 0", "dim(shapes.Y, 2) % 4 == 0"],
|
| 41 |
+
"constants": {
|
| 42 |
+
"scalar": "dtypes.T",
|
| 43 |
+
"usesF16": "dtypes.T == \"f16\"",
|
| 44 |
+
"vec4": true,
|
| 45 |
+
"vec4Tail": false,
|
| 46 |
+
"vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"",
|
| 47 |
+
"hidden": "dim(shapes.X, ranks.X - 1) / 2 if dim(shapes.X, ranks.X - 1) > 0 else 1",
|
| 48 |
+
"twice": "dim(shapes.X, ranks.X - 1) if dim(shapes.X, ranks.X - 1) > 0 else 2"
|
| 49 |
+
},
|
| 50 |
+
"passes": [
|
| 51 |
+
{
|
| 52 |
+
"id": "main",
|
| 53 |
+
"name": "BiasSplitGelu.vec4",
|
| 54 |
+
"shader": "bias-split-gelu.wgsl.jinja",
|
| 55 |
+
"bindings": [
|
| 56 |
+
{
|
| 57 |
+
"name": "x",
|
| 58 |
+
"arg": "X",
|
| 59 |
+
"semantic": "X",
|
| 60 |
+
"buffer": { "type": "read-only-storage" },
|
| 61 |
+
"elementType": "$scalar"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "bias",
|
| 65 |
+
"arg": "bias",
|
| 66 |
+
"semantic": "bias",
|
| 67 |
+
"buffer": { "type": "read-only-storage" },
|
| 68 |
+
"elementType": "$scalar",
|
| 69 |
+
"length": "$twice"
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"name": "y",
|
| 73 |
+
"arg": "Y",
|
| 74 |
+
"semantic": "Y",
|
| 75 |
+
"buffer": { "type": "storage" },
|
| 76 |
+
"elementType": "$vectorScalar"
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"name": "params",
|
| 80 |
+
"semantic": "kernel.params",
|
| 81 |
+
"buffer": { "type": "uniform" },
|
| 82 |
+
"struct": {
|
| 83 |
+
"name": "Params",
|
| 84 |
+
"fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.Y) / 4" }]
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
],
|
| 88 |
+
"dispatch": { "threads": "numel(shapes.Y) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 89 |
+
}
|
| 90 |
+
]
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"id": "vec4_tail",
|
| 94 |
+
"priority": 20,
|
| 95 |
+
"when": ["ranks.X == 3", "ranks.Y == 3", "dim(shapes.Y, 0) == dim(shapes.X, 0)", "dim(shapes.Y, 1) == dim(shapes.X, 1)", "dim(shapes.X, 2) % 2 == 0", "dim(shapes.Y, 2) == dim(shapes.X, 2) / 2", "f16Ok(dtypes.T)", "ranks.bias == 1", "dim(shapes.bias, 0) == dim(shapes.X, 2)", "numel(shapes.Y) > 0"],
|
| 96 |
+
"constants": {
|
| 97 |
+
"scalar": "dtypes.T",
|
| 98 |
+
"usesF16": "dtypes.T == \"f16\"",
|
| 99 |
+
"vec4": false,
|
| 100 |
+
"vec4Tail": true,
|
| 101 |
+
"hidden": "dim(shapes.X, ranks.X - 1) / 2 if dim(shapes.X, ranks.X - 1) > 0 else 1",
|
| 102 |
+
"twice": "dim(shapes.X, ranks.X - 1) if dim(shapes.X, ranks.X - 1) > 0 else 2"
|
| 103 |
+
},
|
| 104 |
+
"passes": [
|
| 105 |
+
{
|
| 106 |
+
"id": "main",
|
| 107 |
+
"name": "BiasSplitGelu.vec4Tail",
|
| 108 |
+
"shader": "bias-split-gelu.wgsl.jinja",
|
| 109 |
+
"bindings": [
|
| 110 |
+
{
|
| 111 |
+
"name": "x",
|
| 112 |
+
"arg": "X",
|
| 113 |
+
"semantic": "X",
|
| 114 |
+
"buffer": { "type": "read-only-storage" },
|
| 115 |
+
"elementType": "$scalar"
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"name": "bias",
|
| 119 |
+
"arg": "bias",
|
| 120 |
+
"semantic": "bias",
|
| 121 |
+
"buffer": { "type": "read-only-storage" },
|
| 122 |
+
"elementType": "$scalar",
|
| 123 |
+
"length": "$twice"
|
| 124 |
+
},
|
| 125 |
+
{ "name": "y", "arg": "Y", "semantic": "Y", "buffer": { "type": "storage" }, "elementType": "$scalar" },
|
| 126 |
+
{
|
| 127 |
+
"name": "params",
|
| 128 |
+
"semantic": "kernel.params",
|
| 129 |
+
"buffer": { "type": "uniform" },
|
| 130 |
+
"struct": {
|
| 131 |
+
"name": "Params",
|
| 132 |
+
"fields": [
|
| 133 |
+
{
|
| 134 |
+
"name": "count",
|
| 135 |
+
"type": "u32",
|
| 136 |
+
"value": "(numel(shapes.Y) / (dim(shapes.X, ranks.X - 1) / 2)) * ceilDiv(dim(shapes.X, ranks.X - 1) / 2, 4)"
|
| 137 |
+
}
|
| 138 |
+
]
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
],
|
| 142 |
+
"dispatch": {
|
| 143 |
+
"threads": "(numel(shapes.Y) / (dim(shapes.X, ranks.X - 1) / 2)) * ceilDiv(dim(shapes.X, ranks.X - 1) / 2, 4)",
|
| 144 |
+
"workgroupSize": "tunables.WORKGROUP_SIZE"
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
]
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"id": "scalar",
|
| 151 |
+
"priority": 0,
|
| 152 |
+
"when": ["ranks.X == 3", "ranks.Y == 3", "dim(shapes.Y, 0) == dim(shapes.X, 0)", "dim(shapes.Y, 1) == dim(shapes.X, 1)", "dim(shapes.X, 2) % 2 == 0", "dim(shapes.Y, 2) == dim(shapes.X, 2) / 2", "f16Ok(dtypes.T)", "ranks.bias == 1", "dim(shapes.bias, 0) == dim(shapes.X, 2)", "true"],
|
| 153 |
+
"constants": {
|
| 154 |
+
"scalar": "dtypes.T",
|
| 155 |
+
"usesF16": "dtypes.T == \"f16\"",
|
| 156 |
+
"vec4": false,
|
| 157 |
+
"vec4Tail": false,
|
| 158 |
+
"hidden": "dim(shapes.X, ranks.X - 1) / 2 if dim(shapes.X, ranks.X - 1) > 0 else 1",
|
| 159 |
+
"twice": "dim(shapes.X, ranks.X - 1) if dim(shapes.X, ranks.X - 1) > 0 else 2"
|
| 160 |
+
},
|
| 161 |
+
"passes": [
|
| 162 |
+
{
|
| 163 |
+
"id": "main",
|
| 164 |
+
"name": "BiasSplitGelu.scalar",
|
| 165 |
+
"shader": "bias-split-gelu.wgsl.jinja",
|
| 166 |
+
"bindings": [
|
| 167 |
+
{
|
| 168 |
+
"name": "x",
|
| 169 |
+
"arg": "X",
|
| 170 |
+
"semantic": "X",
|
| 171 |
+
"buffer": { "type": "read-only-storage" },
|
| 172 |
+
"elementType": "$scalar"
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"name": "bias",
|
| 176 |
+
"arg": "bias",
|
| 177 |
+
"semantic": "bias",
|
| 178 |
+
"buffer": { "type": "read-only-storage" },
|
| 179 |
+
"elementType": "$scalar"
|
| 180 |
+
},
|
| 181 |
+
{ "name": "y", "arg": "Y", "semantic": "Y", "buffer": { "type": "storage" }, "elementType": "$scalar" },
|
| 182 |
+
{
|
| 183 |
+
"name": "params",
|
| 184 |
+
"semantic": "kernel.params",
|
| 185 |
+
"buffer": { "type": "uniform" },
|
| 186 |
+
"struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.Y)" }] }
|
| 187 |
+
}
|
| 188 |
+
],
|
| 189 |
+
"dispatch": { "threads": "numel(shapes.Y)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 190 |
+
}
|
| 191 |
+
]
|
| 192 |
+
}
|
| 193 |
+
]
|
| 194 |
+
}
|
build/webgpu/metadata.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "com.microsoft.BiasSplitGelu",
|
| 3 |
+
"id": "_com_microsoft_biassplitgelu_webgpu_e56edec",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"backend": { "type": "webgpu" },
|
| 7 |
+
"digest": {
|
| 8 |
+
"algorithm": "sha256",
|
| 9 |
+
"files": {
|
| 10 |
+
"bench.json": "oYxkYz1Ukonqiav8OJSz76L0uidTkGg049tpmfnC0Ms=",
|
| 11 |
+
"bias-split-gelu.wgsl.jinja": "YGnskVbzCTa0y/SN+O6Wq0Yp8SWpUav6Q930/EHEvsw=",
|
| 12 |
+
"manifest.json": "i40t5ZCHmqMoQrSWSWZlC3X/ERSmyoa5z4PkrzsWP/w=",
|
| 13 |
+
"test.json": "JVElcOkuNl49j2nfKWBgotONhDTNVT7ZbWTDW+5Of/Q="
|
| 14 |
+
}
|
| 15 |
+
},
|
| 16 |
+
"provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } },
|
| 17 |
+
"webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/com.microsoft.BiasSplitGelu" }
|
| 18 |
+
}
|
build/webgpu/test.json
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"op": "com.microsoft.BiasSplitGelu",
|
| 3 |
+
"cases": [
|
| 4 |
+
{
|
| 5 |
+
"name": "dispatch_cliff_vec4_over_16M",
|
| 6 |
+
"requires": { "limits": { "maxBufferSize": 536862752, "maxStorageBufferBindingSize": 536862752 } },
|
| 7 |
+
"provenance": {
|
| 8 |
+
"notes": "Its largest tensor is 536862752 bytes, so the case needs an adapter whose maxBufferSize and maxStorageBufferBindingSize both reach it — declared, because the WebGPU guaranteed minimums (256 MiB / 128 MiB) do not, and a device at them must report the case inapplicable rather than fail allocating it."
|
| 9 |
+
},
|
| 10 |
+
"inputs": {
|
| 11 |
+
"X": {
|
| 12 |
+
"dtype": "float32",
|
| 13 |
+
"shape": [1, 16776961, 8],
|
| 14 |
+
"data": { "kind": "linspace", "start": -1.0, "end": 1.0 }
|
| 15 |
+
},
|
| 16 |
+
"bias": { "dtype": "float32", "shape": [8], "data": { "kind": "linspace", "start": -0.5, "end": 0.5 } }
|
| 17 |
+
},
|
| 18 |
+
"outputs": { "Y": { "dtype": "float32", "shape": [1, 16776961, 4], "tolerance": 0.0001 } }
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"name": "ort_split_last_dim_then_gelu_gate",
|
| 22 |
+
"provenance": {
|
| 23 |
+
"source": "onnxruntime/test/contrib_ops/bias_split_gelu_op_test.cc",
|
| 24 |
+
"test": "BiasSplitGeluTest.BiasSplitGeluTest_HiddenSize_2560",
|
| 25 |
+
"notes": "Small deterministic projection of ORT's fused bias+split+Gelu gate pattern."
|
| 26 |
+
},
|
| 27 |
+
"inputs": {
|
| 28 |
+
"X": {
|
| 29 |
+
"dtype": "float32",
|
| 30 |
+
"shape": [1, 2, 4],
|
| 31 |
+
"data": { "kind": "values", "values": [1.0, 2.0, 0.0, 1.0, -1.0, 0.5, 2.0, -2.0] }
|
| 32 |
+
},
|
| 33 |
+
"bias": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.5, -0.5, 1.0, -1.0] } }
|
| 34 |
+
},
|
| 35 |
+
"outputs": {
|
| 36 |
+
"Y": {
|
| 37 |
+
"dtype": "float32",
|
| 38 |
+
"shape": [1, 2, 2],
|
| 39 |
+
"tolerance": 0.000001,
|
| 40 |
+
"relTolerance": 0.000001,
|
| 41 |
+
"data": { "kind": "values", "values": [1.262017119103, 0.0, -1.497975152953, 0.0] }
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"name": "ort_projection_sequence_len1",
|
| 47 |
+
"provenance": {
|
| 48 |
+
"source": "onnxruntime/test/contrib_ops/bias_split_gelu_op_test.cc",
|
| 49 |
+
"test": "BiasSplitGeluTest.BiasSplitGeluTest_HiddenSize_5120",
|
| 50 |
+
"notes": "Compact deterministic projection of ORT's batch=2, sequence_length=1 shape coverage."
|
| 51 |
+
},
|
| 52 |
+
"inputs": {
|
| 53 |
+
"X": {
|
| 54 |
+
"dtype": "float32",
|
| 55 |
+
"shape": [2, 1, 6],
|
| 56 |
+
"data": { "kind": "values", "values": [1.0, -1.0, 0.5, 2.0, -2.0, 0.0, -0.25, 0.75, -1.5, 1.5, 0.25, -0.5] }
|
| 57 |
+
},
|
| 58 |
+
"bias": {
|
| 59 |
+
"dtype": "float32",
|
| 60 |
+
"shape": [6],
|
| 61 |
+
"data": { "kind": "values", "values": [0.25, -0.5, 0.75, -1.0, 0.5, -0.25] }
|
| 62 |
+
}
|
| 63 |
+
},
|
| 64 |
+
"outputs": {
|
| 65 |
+
"Y": {
|
| 66 |
+
"dtype": "float32",
|
| 67 |
+
"shape": [2, 1, 3],
|
| 68 |
+
"tolerance": 0.000001,
|
| 69 |
+
"relTolerance": 0.000001,
|
| 70 |
+
"data": {
|
| 71 |
+
"kind": "values",
|
| 72 |
+
"values": [1.05168092, 0.1503162697, -0.1254042904, 0.0, 0.1450073842, 0.1274778475]
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"name": "ort_projection_batch1_sequence2",
|
| 79 |
+
"provenance": {
|
| 80 |
+
"source": "onnxruntime/test/contrib_ops/bias_split_gelu_op_test.cc",
|
| 81 |
+
"test": "BiasSplitGeluTest.BiasSplitGeluTest_HiddenSize_10240",
|
| 82 |
+
"notes": "Compact deterministic projection of ORT's batch=1, sequence_length=2 shape coverage."
|
| 83 |
+
},
|
| 84 |
+
"inputs": {
|
| 85 |
+
"X": {
|
| 86 |
+
"dtype": "float32",
|
| 87 |
+
"shape": [1, 2, 6],
|
| 88 |
+
"data": { "kind": "values", "values": [1.0, 2.0, -1.0, 0.0, 0.5, -0.5, -2.0, 1.5, 0.25, 2.5, -1.0, 0.0] }
|
| 89 |
+
},
|
| 90 |
+
"bias": {
|
| 91 |
+
"dtype": "float32",
|
| 92 |
+
"shape": [6],
|
| 93 |
+
"data": { "kind": "values", "values": [0.25, -0.5, 0.75, -1.0, 0.5, -0.25] }
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"outputs": {
|
| 97 |
+
"Y": {
|
| 98 |
+
"dtype": "float32",
|
| 99 |
+
"shape": [1, 2, 3],
|
| 100 |
+
"tolerance": 0.000001,
|
| 101 |
+
"relTolerance": 0.000001,
|
| 102 |
+
"data": {
|
| 103 |
+
"kind": "values",
|
| 104 |
+
"values": [-0.1983190798, 1.262017104, 0.04249261584, -2.449631019, -0.1542687686, -0.1003234323]
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"name": "ort_projection_batch2_sequence3_vec4",
|
| 111 |
+
"provenance": {
|
| 112 |
+
"source": "onnxruntime/test/contrib_ops/bias_split_gelu_op_test.cc",
|
| 113 |
+
"test": "BiasSplitGeluTest.BiasSplitGeluTest_HiddenSize_6144",
|
| 114 |
+
"notes": "Compact deterministic projection of ORT's batch=2, sequence_length=3 shape coverage with output hidden divisible by 4."
|
| 115 |
+
},
|
| 116 |
+
"inputs": {
|
| 117 |
+
"X": {
|
| 118 |
+
"dtype": "float32",
|
| 119 |
+
"shape": [2, 3, 8],
|
| 120 |
+
"data": {
|
| 121 |
+
"kind": "values",
|
| 122 |
+
"values": [1.0, -1.0, 0.5, -0.5, 2.0, -2.0, 0.25, -0.25, -1.5, 1.5, 0.0, -0.75, 0.75, -0.5, 1.25, -1.25, 3.0, -3.0, 0.5, -0.5, -2.0, 2.0, 1.0, -1.0, 0.0, 1.0, -1.0, 0.5, -0.5, 2.5, -2.5, 1.5, 0.125, -0.125, 4.0, -4.0, 0.75, -0.75, 1.5, -1.5, 2.25, -2.25, 0.333, -0.333, 5.0, -5.0, 1.25, -1.25]
|
| 123 |
+
}
|
| 124 |
+
},
|
| 125 |
+
"bias": {
|
| 126 |
+
"dtype": "float32",
|
| 127 |
+
"shape": [8],
|
| 128 |
+
"data": { "kind": "values", "values": [0.25, -0.5, 0.75, -1.0, 0.5, -0.25, 1.5, -1.5] }
|
| 129 |
+
}
|
| 130 |
+
},
|
| 131 |
+
"outputs": {
|
| 132 |
+
"Y": {
|
| 133 |
+
"dtype": "float32",
|
| 134 |
+
"shape": [2, 3, 4],
|
| 135 |
+
"tolerance": 0.000001,
|
| 136 |
+
"relTolerance": 0.000001,
|
| 137 |
+
"data": {
|
| 138 |
+
"kind": "values",
|
| 139 |
+
"values": [3.1055946350097656, 0.04125746339559555, 2.0998706817626953, 0.10515517741441727, -1.3974220752716064, -0.16997046768665314, 2.05635404586792, 0.014340377412736416, -0.3256852626800537, -5.879637718200684, 3.1055946350097656, 0.023286299780011177, 0.0, 1.1112475395202637, 0.03966381773352623, 0.0, 0.41922664642333984, 0.09915953874588013, 14.23076343536377, 0.020249508321285248, 13.75, 0.0000011001571920132847, 2.9693753719329834, 0.010923270136117935]
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"name": "split_gelu_d4_vec4_path",
|
| 146 |
+
"provenance": {
|
| 147 |
+
"source": "onnxruntime/test/contrib_ops/bias_split_gelu_op_test.cc",
|
| 148 |
+
"notes": "D=4 (input hidden 8) so the output hidden axis is a multiple of 4 and the vec4 manifest variant is exercised. Expected values from the same erf-form GEGLU gate computed at f64 then f32-rounded."
|
| 149 |
+
},
|
| 150 |
+
"inputs": {
|
| 151 |
+
"X": {
|
| 152 |
+
"dtype": "float32",
|
| 153 |
+
"shape": [1, 1, 8],
|
| 154 |
+
"data": { "kind": "values", "values": [0.5, -1.0, 2.0, -0.5, 1.5, 0.0, -2.0, 1.0] }
|
| 155 |
+
},
|
| 156 |
+
"bias": {
|
| 157 |
+
"dtype": "float32",
|
| 158 |
+
"shape": [8],
|
| 159 |
+
"data": { "kind": "values", "values": [0.25, 0.5, -0.5, 1.0, -1.0, 0.5, 2.0, -0.25] }
|
| 160 |
+
}
|
| 161 |
+
},
|
| 162 |
+
"outputs": {
|
| 163 |
+
"Y": {
|
| 164 |
+
"dtype": "float32",
|
| 165 |
+
"shape": [1, 1, 4],
|
| 166 |
+
"tolerance": 0.000001,
|
| 167 |
+
"relTolerance": 0.000001,
|
| 168 |
+
"data": { "kind": "values", "values": [0.2592984235214977, -0.17286561568099845, 0.0, 0.2900147683230033] }
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"name": "empty_zero_dim",
|
| 174 |
+
"provenance": {
|
| 175 |
+
"notes": "Zero-length batch axis of X (empty input). ONNX treats empty tensors as first-class; output is the same broadcast shape with the 0 batch ⇒ EMPTY output. bias kept at its normal rank-1 non-zero shape."
|
| 176 |
+
},
|
| 177 |
+
"inputs": {
|
| 178 |
+
"X": { "dtype": "float32", "shape": [0, 2, 4], "data": { "kind": "values", "values": [] } },
|
| 179 |
+
"bias": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.5, -0.5, 1.0, -1.0] } }
|
| 180 |
+
},
|
| 181 |
+
"outputs": {
|
| 182 |
+
"Y": { "dtype": "float32", "shape": [0, 2, 2], "tolerance": 0, "data": { "kind": "values", "values": [] } }
|
| 183 |
+
}
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"name": "empty_zero_dim_f16",
|
| 187 |
+
"provenance": { "notes": "f16 variant of the empty zero-batch-axis case." },
|
| 188 |
+
"inputs": {
|
| 189 |
+
"X": { "dtype": "float16", "shape": [0, 2, 4], "data": { "kind": "values", "values": [] } },
|
| 190 |
+
"bias": { "dtype": "float16", "shape": [4], "data": { "kind": "values", "values": [0.5, -0.5, 1.0, -1.0] } }
|
| 191 |
+
},
|
| 192 |
+
"outputs": {
|
| 193 |
+
"Y": { "dtype": "float16", "shape": [0, 2, 2], "tolerance": 0, "data": { "kind": "values", "values": [] } }
|
| 194 |
+
}
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"name": "empty_zero_hidden",
|
| 198 |
+
"provenance": {
|
| 199 |
+
"notes": "Zero-length hidden axis: bias stays 2x the (zero) half-width, so both the bias vector and the split halves are empty and no kernel may size a binding from the hidden extent."
|
| 200 |
+
},
|
| 201 |
+
"inputs": {
|
| 202 |
+
"X": { "dtype": "float32", "shape": [1, 2, 0], "data": { "kind": "values", "values": [] } },
|
| 203 |
+
"bias": { "dtype": "float32", "shape": [0], "data": { "kind": "values", "values": [] } }
|
| 204 |
+
},
|
| 205 |
+
"outputs": {
|
| 206 |
+
"Y": { "dtype": "float32", "shape": [1, 2, 0], "tolerance": 0, "data": { "kind": "values", "values": [] } }
|
| 207 |
+
}
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"name": "f16_vec4_shader_validation",
|
| 211 |
+
"provenance": {
|
| 212 |
+
"notes": "Non-empty f16 D=4 case forces the vec4 variant; the empty f16 case cannot catch shader construction errors because it returns before compiling meaningful lane loads."
|
| 213 |
+
},
|
| 214 |
+
"inputs": {
|
| 215 |
+
"X": {
|
| 216 |
+
"dtype": "float16",
|
| 217 |
+
"shape": [1, 1, 8],
|
| 218 |
+
"data": { "kind": "values", "values": [0.5, -1.0, 2.0, -0.5, 1.5, 0.0, -2.0, 1.0] }
|
| 219 |
+
},
|
| 220 |
+
"bias": {
|
| 221 |
+
"dtype": "float16",
|
| 222 |
+
"shape": [8],
|
| 223 |
+
"data": { "kind": "values", "values": [0.25, 0.5, -0.5, 1.0, -1.0, 0.5, 2.0, -0.25] }
|
| 224 |
+
}
|
| 225 |
+
},
|
| 226 |
+
"outputs": { "Y": { "dtype": "float16", "shape": [1, 1, 4], "tolerance": 0.01 } }
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
"name": "scalar_path_dispatch_fold_over_16M",
|
| 230 |
+
"provenance": {
|
| 231 |
+
"notes": "D=6 (twice=12, 6%4!=0) forces the scalar variant; numel(Y)=16776966 > 65535*256 forces the scalar-branch 2D dispatch fold (gid.y high bits), an untested path (dispatch_cliff_vec4_over_16M covers only the vec4 branch). Validates the i=gid.x+gid.y*nwg.x*WG reconstruction and i>=count tail guard on the last rows."
|
| 232 |
+
},
|
| 233 |
+
"inputs": {
|
| 234 |
+
"X": {
|
| 235 |
+
"dtype": "float32",
|
| 236 |
+
"shape": [1, 2796161, 12],
|
| 237 |
+
"data": { "kind": "linspace", "start": -1.0, "end": 1.0 }
|
| 238 |
+
},
|
| 239 |
+
"bias": { "dtype": "float32", "shape": [12], "data": { "kind": "linspace", "start": -0.5, "end": 0.5 } }
|
| 240 |
+
},
|
| 241 |
+
"outputs": { "Y": { "dtype": "float32", "shape": [1, 2796161, 6], "tolerance": 0.0001 } }
|
| 242 |
+
},
|
| 243 |
+
{
|
| 244 |
+
"name": "scalar_path_odd_hidden_d6",
|
| 245 |
+
"provenance": {
|
| 246 |
+
"notes": "twice=12, D=6 (6%4!=0) routes to the scalar variant; small case verifying scalar split-index math (value half [0:6], gate half [6:12]) at a hidden size not covered by existing D=3 scalar cases. Reference supplies truth."
|
| 247 |
+
},
|
| 248 |
+
"inputs": {
|
| 249 |
+
"X": {
|
| 250 |
+
"dtype": "float32",
|
| 251 |
+
"shape": [1, 2, 12],
|
| 252 |
+
"data": {
|
| 253 |
+
"kind": "values",
|
| 254 |
+
"values": [1.0, -1.0, 0.5, -0.5, 2.0, -2.0, 0.25, -0.25, 1.5, -1.5, 0.75, -0.75, -2.0, 2.0, 1.0, -1.0, 0.5, -0.5, 3.0, -3.0, 0.125, -0.125, 0.0, 1.0]
|
| 255 |
+
}
|
| 256 |
+
},
|
| 257 |
+
"bias": {
|
| 258 |
+
"dtype": "float32",
|
| 259 |
+
"shape": [12],
|
| 260 |
+
"data": { "kind": "values", "values": [0.25, -0.5, 0.75, -1.0, 0.5, -0.25, 1.5, -1.5, 0.1, -0.1, 0.6, -0.6] }
|
| 261 |
+
}
|
| 262 |
+
},
|
| 263 |
+
"outputs": { "Y": { "dtype": "float32", "shape": [1, 2, 6], "tolerance": 0.000001, "relTolerance": 0.000001 } }
|
| 264 |
+
}
|
| 265 |
+
]
|
| 266 |
+
}
|