| { |
| "domain": "com.microsoft", |
| "name": "Gelu", |
| "sinceVersion": 1, |
| "description": "Applies the Gaussian Error Linear Unit (GELU) activation elementwise: `Y = 0.5 * X * (1 + erf(X / sqrt(2)))`. The output has the same shape as the input. Float16 and float32 are supported; the schema's double and bfloat16 types are not.", |
| "inputs": [ |
| { "role": "X", "dtype": "T", "description": "Values transformed elementwise by the exact GELU activation." } |
| ], |
| "outputs": [ |
| { |
| "role": "Y", |
| "dtype": "T", |
| "rank": "ranks.X", |
| "shape": "shapes.X", |
| "description": "Output tensor after applying GELU; same shape as the input." |
| } |
| ], |
| "typeConstraints": { "T": ["float32", "float16"] }, |
| "args": { |
| "X": { "kind": "tensor", "semantic": "X", "role": "input" }, |
| "Y": { "kind": "tensor", "semantic": "Y", "role": "output" } |
| }, |
| "tunables": { "WORKGROUP_SIZE": 256 }, |
| "constants": { |
| "scalar": "dtypes.T", |
| "usesF16": "dtypes.T == \"f16\"", |
| "approximate": "\"erf\"", |
| "vec4Tail": false, |
| "hasBias": false |
| }, |
| "variants": [ |
| { |
| "id": "vec4", |
| "priority": 20, |
| "when": ["numel(shapes.X) == numel(shapes.Y)", "f16Ok(dtypes.T)", "numel(shapes.X) > 0", "numel(shapes.X) % 4 == 0"], |
| "constants": { "vec4": true, "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" }, |
| "passes": [ |
| { |
| "id": "main", |
| "name": "Gelu.vec4", |
| "shader": "elementwise-bias-gelu.wgsl.jinja", |
| "bindings": [ |
| { |
| "name": "x", |
| "arg": "X", |
| "semantic": "X", |
| "buffer": { "type": "read-only-storage" }, |
| "elementType": "$vectorScalar" |
| }, |
| { |
| "name": "y", |
| "arg": "Y", |
| "semantic": "Y", |
| "buffer": { "type": "storage" }, |
| "elementType": "$vectorScalar" |
| }, |
| { |
| "name": "params", |
| "semantic": "kernel.params", |
| "buffer": { "type": "uniform" }, |
| "struct": { |
| "name": "Params", |
| "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.X) / 4" }] |
| } |
| } |
| ], |
| "dispatch": { "threads": "numel(shapes.X) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" } |
| } |
| ] |
| }, |
| { |
| "id": "scalar", |
| "priority": 0, |
| "when": ["numel(shapes.X) == numel(shapes.Y)", "f16Ok(dtypes.T)"], |
| "constants": { "vec4": false }, |
| "passes": [ |
| { |
| "id": "main", |
| "name": "Gelu.scalar", |
| "shader": "elementwise-bias-gelu.wgsl.jinja", |
| "bindings": [ |
| { |
| "name": "x", |
| "arg": "X", |
| "semantic": "X", |
| "buffer": { "type": "read-only-storage" }, |
| "elementType": "$scalar" |
| }, |
| { "name": "y", "arg": "Y", "semantic": "Y", "buffer": { "type": "storage" }, "elementType": "$scalar" }, |
| { |
| "name": "params", |
| "semantic": "kernel.params", |
| "buffer": { "type": "uniform" }, |
| "struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.X)" }] } |
| } |
| ], |
| "dispatch": { "threads": "numel(shapes.X)", "workgroupSize": "tunables.WORKGROUP_SIZE" } |
| } |
| ] |
| } |
| ] |
| } |
|
|