sync 2e7068faf55e
Browse files- README.md +59 -0
- build/webgpu/bench.json +26 -0
- build/webgpu/dropout-vec4.wgsl.jinja +20 -0
- build/webgpu/dropout.wgsl.jinja +46 -0
- build/webgpu/manifest.json +152 -0
- build/webgpu/metadata.json +19 -0
- build/webgpu/test.json +127 -0
README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
| 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 |
+
# ai.onnx.Dropout
|
| 10 |
+
|
| 11 |
+
`ai.onnx` · standard ONNX operator · ONNX opset ≥ 13
|
| 12 |
+
|
| 13 |
+
## Description
|
| 14 |
+
|
| 15 |
+
Inference-only Dropout. Copies a floating-point tensor unchanged and optionally emits an all-true boolean mask. The `ratio` and `training_mode` inputs, seeded randomness, and training behavior are not supported by this package.
|
| 16 |
+
|
| 17 |
+
See the [ONNX `Dropout` spec](https://onnx.ai/onnx/operators/onnx__Dropout.html) for the reference semantics.
|
| 18 |
+
|
| 19 |
+
## Inputs
|
| 20 |
+
|
| 21 |
+
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|
| 22 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 23 |
+
| `data` | `x` | `T` | — | — | The input floating-point tensor to copy unchanged. | required |
|
| 24 |
+
|
| 25 |
+
## Outputs
|
| 26 |
+
|
| 27 |
+
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|
| 28 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 29 |
+
| `output` | `y` | `T` | same as `data` | same as `data` | The output tensor, same shape as the input; equals the input in inference mode. | required |
|
| 30 |
+
| `mask` | `mask` | `M` | same as `data` | same as `data` | Boolean mask indicating which elements were kept (all-ones in inference mode). | optional |
|
| 31 |
+
|
| 32 |
+
## Type constraints
|
| 33 |
+
|
| 34 |
+
| Variable | Allowed dtypes |
|
| 35 |
+
| --- | --- |
|
| 36 |
+
| `T` | `float32`, `float16` |
|
| 37 |
+
| `M` | `bool` |
|
| 38 |
+
|
| 39 |
+
## Files
|
| 40 |
+
|
| 41 |
+
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, provenance)
|
| 42 |
+
- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
|
| 43 |
+
- [`test.json`](build/webgpu/test.json) — correctness cases
|
| 44 |
+
- [`bench.json`](build/webgpu/bench.json) — benchmark + tuning cases
|
| 45 |
+
- [`dropout-vec4.wgsl.jinja`](build/webgpu/dropout-vec4.wgsl.jinja)
|
| 46 |
+
- [`dropout.wgsl.jinja`](build/webgpu/dropout.wgsl.jinja)
|
| 47 |
+
|
| 48 |
+
## Use with `@huggingface/kernels`
|
| 49 |
+
|
| 50 |
+
The loader derives every required output's shape and logical dtype from the manifest contract and this call.
|
| 51 |
+
It then allocates the result tensors 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 |
+
|
| 55 |
+
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
|
| 56 |
+
|
| 57 |
+
```js
|
| 58 |
+
import { getKernel } from "@huggingface/kernels";
|
| 59 |
+
|
| 60 |
+
const kernel = await getKernel("webgpu-kernels/ai.onnx.Dropout", { version: 1 });
|
| 61 |
+
const { y } = await kernel({ x: { data: xData, shape: [] } });
|
| 62 |
+
```
|
build/webgpu/bench.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"op": "ai.onnx.Dropout",
|
| 3 |
+
"cases": [
|
| 4 |
+
{
|
| 5 |
+
"name": "f32_16m",
|
| 6 |
+
"preset": "smoke",
|
| 7 |
+
"inputs": { "x": { "dtype": "float32", "shape": [16777216], "dist": "normal", "seed": 771, "scale": 1 } },
|
| 8 |
+
"outputs": { "y": { "dtype": "float32", "shape": [16777216] } },
|
| 9 |
+
"bench": { "primary": true, "metrics": [{ "type": "bandwidth", "value": "16777216 * 4 * 2" }] }
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"name": "f32_1m",
|
| 13 |
+
"preset": "smoke",
|
| 14 |
+
"inputs": { "x": { "dtype": "float32", "shape": [1048576] } },
|
| 15 |
+
"outputs": { "y": { "dtype": "float32", "shape": [1048576] } },
|
| 16 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "(numel(shapes.x) + numel(shapes.y)) * 4" }] }
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"name": "f32_scalar_path_non_aligned",
|
| 20 |
+
"preset": "edge",
|
| 21 |
+
"inputs": { "x": { "dtype": "float32", "shape": [16777213], "dist": "normal", "seed": 883, "scale": 1 } },
|
| 22 |
+
"outputs": { "y": { "dtype": "float32", "shape": [16777213] } },
|
| 23 |
+
"bench": { "metrics": [{ "type": "bandwidth", "value": "16777213 * 4 * 2" }] }
|
| 24 |
+
}
|
| 25 |
+
]
|
| 26 |
+
}
|
build/webgpu/dropout-vec4.wgsl.jinja
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% if usesF16 %}
|
| 2 |
+
enable f16;
|
| 3 |
+
{% endif %}
|
| 4 |
+
{{ env.wgsl.resourceDeclarations }}
|
| 5 |
+
|
| 6 |
+
// Vec4 inference Dropout: pure contiguous copy (Y = X) with mask = 1, 4 elements
|
| 7 |
+
// per thread. A device-capped grid stride covers arbitrary output lengths.
|
| 8 |
+
const COUNT: u32 = {{ source.count }}u;
|
| 9 |
+
const WG: u32 = {{ tunables.WORKGROUP_SIZE }}u;
|
| 10 |
+
|
| 11 |
+
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
|
| 12 |
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
|
| 13 |
+
let stride = nwg.x * WG;
|
| 14 |
+
for (var i = gid.x; i < COUNT; i = i + stride) {
|
| 15 |
+
y[i] = x[i];
|
| 16 |
+
{% if hasMask %}
|
| 17 |
+
mask[i] = vec4<u32>(1u);
|
| 18 |
+
{% endif %}
|
| 19 |
+
}
|
| 20 |
+
}
|
build/webgpu/dropout.wgsl.jinja
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
|
| 40 |
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
|
| 41 |
+
{{ flat_index_2d(note="limit") }}
|
| 42 |
+
y[i] = x[i];
|
| 43 |
+
{% if hasMask %}
|
| 44 |
+
mask[i] = 1u;
|
| 45 |
+
{% endif %}
|
| 46 |
+
}
|
build/webgpu/manifest.json
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"domain": "ai.onnx",
|
| 3 |
+
"name": "Dropout",
|
| 4 |
+
"sinceVersion": 13,
|
| 5 |
+
"description": "Inference-only Dropout. Copies a floating-point tensor unchanged and optionally emits an all-true boolean mask. The `ratio` and `training_mode` inputs, seeded randomness, and training behavior are not supported by this package.",
|
| 6 |
+
"inputs": [{ "role": "data", "dtype": "T", "description": "The input floating-point tensor to copy unchanged." }],
|
| 7 |
+
"outputs": [
|
| 8 |
+
{
|
| 9 |
+
"role": "output",
|
| 10 |
+
"dtype": "T",
|
| 11 |
+
"rank": "ranks.data",
|
| 12 |
+
"description": "The output tensor, same shape as the input; equals the input in inference mode.",
|
| 13 |
+
"shape": "shapes.data"
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"role": "mask",
|
| 17 |
+
"dtype": "M",
|
| 18 |
+
"rank": "ranks.data",
|
| 19 |
+
"shape": "shapes.data",
|
| 20 |
+
"optional": true,
|
| 21 |
+
"description": "Boolean mask indicating which elements were kept (all-ones in inference mode)."
|
| 22 |
+
}
|
| 23 |
+
],
|
| 24 |
+
"typeConstraints": { "T": ["float32", "float16"], "M": ["bool"] },
|
| 25 |
+
"args": {
|
| 26 |
+
"x": { "kind": "tensor", "semantic": "data", "role": "x" },
|
| 27 |
+
"y": { "kind": "tensor", "semantic": "output", "role": "y" },
|
| 28 |
+
"mask": { "kind": "tensor", "semantic": "mask", "role": "mask", "required": false }
|
| 29 |
+
},
|
| 30 |
+
"tunables": { "WORKGROUP_SIZE": 256 },
|
| 31 |
+
"constants": { "usesF16": "dtypes.T == \"f16\"", "scalar": "dtypes.T" },
|
| 32 |
+
"bindingSets": {
|
| 33 |
+
"inferenceCopyVec4": [
|
| 34 |
+
{
|
| 35 |
+
"name": "x",
|
| 36 |
+
"arg": "x",
|
| 37 |
+
"semantic": "data",
|
| 38 |
+
"buffer": { "type": "read-only-storage" },
|
| 39 |
+
"elementType": "$vectorScalar"
|
| 40 |
+
},
|
| 41 |
+
{ "name": "y", "arg": "y", "semantic": "output", "buffer": { "type": "storage" }, "elementType": "$vectorScalar" }
|
| 42 |
+
],
|
| 43 |
+
"inferenceCopyMaskVec4": [
|
| 44 |
+
{
|
| 45 |
+
"name": "x",
|
| 46 |
+
"arg": "x",
|
| 47 |
+
"semantic": "data",
|
| 48 |
+
"buffer": { "type": "read-only-storage" },
|
| 49 |
+
"elementType": "$vectorScalar"
|
| 50 |
+
},
|
| 51 |
+
{ "name": "y", "arg": "y", "semantic": "output", "buffer": { "type": "storage" }, "elementType": "$vectorScalar" },
|
| 52 |
+
{ "name": "mask", "arg": "mask", "semantic": "mask", "buffer": { "type": "storage" }, "elementType": "vec4<u32>" }
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
"variants": [
|
| 56 |
+
{
|
| 57 |
+
"id": "inference_copy_vec4",
|
| 58 |
+
"priority": 20,
|
| 59 |
+
"when": ["not present.mask", "numel(shapes.data) == numel(shapes.output)", "numel(shapes.output) > 0", "numel(shapes.output) % 4 == 0", "f16Ok(dtypes.T)"],
|
| 60 |
+
"constants": { "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"", "hasMask": false },
|
| 61 |
+
"passes": [
|
| 62 |
+
{
|
| 63 |
+
"id": "main",
|
| 64 |
+
"name": "Dropout.InferenceCopyVec4",
|
| 65 |
+
"source": { "shader": "dropout-vec4.wgsl.jinja", "inputs": { "count": "numel(shapes.output) / 4" } },
|
| 66 |
+
"bindings": "inferenceCopyVec4",
|
| 67 |
+
"dispatch": { "gridStride": "numel(shapes.output) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 68 |
+
}
|
| 69 |
+
]
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"id": "inference_copy_mask_vec4",
|
| 73 |
+
"priority": 20,
|
| 74 |
+
"when": ["present.mask", "numel(shapes.data) == numel(shapes.output)", "numel(shapes.mask) == numel(shapes.output)", "numel(shapes.output) > 0", "numel(shapes.output) % 4 == 0", "f16Ok(dtypes.T)"],
|
| 75 |
+
"constants": { "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"", "hasMask": true },
|
| 76 |
+
"passes": [
|
| 77 |
+
{
|
| 78 |
+
"id": "main",
|
| 79 |
+
"name": "Dropout.InferenceCopyMaskVec4",
|
| 80 |
+
"source": { "shader": "dropout-vec4.wgsl.jinja", "inputs": { "count": "numel(shapes.output) / 4" } },
|
| 81 |
+
"bindings": "inferenceCopyMaskVec4",
|
| 82 |
+
"dispatch": { "gridStride": "numel(shapes.output) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 83 |
+
}
|
| 84 |
+
]
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"id": "inference_copy",
|
| 88 |
+
"when": ["not present.mask", "numel(shapes.data) == numel(shapes.output)", "f16Ok(dtypes.T)"],
|
| 89 |
+
"constants": { "hasMask": false },
|
| 90 |
+
"passes": [
|
| 91 |
+
{
|
| 92 |
+
"id": "main",
|
| 93 |
+
"name": "Dropout.InferenceCopy",
|
| 94 |
+
"shader": "dropout.wgsl.jinja",
|
| 95 |
+
"bindings": [
|
| 96 |
+
{
|
| 97 |
+
"name": "x",
|
| 98 |
+
"arg": "x",
|
| 99 |
+
"semantic": "data",
|
| 100 |
+
"buffer": { "type": "read-only-storage" },
|
| 101 |
+
"elementType": "$scalar"
|
| 102 |
+
},
|
| 103 |
+
{ "name": "y", "arg": "y", "semantic": "output", "buffer": { "type": "storage" }, "elementType": "$scalar" },
|
| 104 |
+
{
|
| 105 |
+
"name": "params",
|
| 106 |
+
"semantic": "kernel.params",
|
| 107 |
+
"buffer": { "type": "uniform" },
|
| 108 |
+
"struct": {
|
| 109 |
+
"name": "Params",
|
| 110 |
+
"fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.output)" }]
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
],
|
| 114 |
+
"dispatch": { "threads": "numel(shapes.output)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 115 |
+
}
|
| 116 |
+
]
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"id": "inference_copy_mask",
|
| 120 |
+
"when": ["present.mask", "numel(shapes.data) == numel(shapes.output)", "numel(shapes.mask) == numel(shapes.output)", "f16Ok(dtypes.T)"],
|
| 121 |
+
"constants": { "hasMask": true },
|
| 122 |
+
"passes": [
|
| 123 |
+
{
|
| 124 |
+
"id": "main",
|
| 125 |
+
"name": "Dropout.InferenceCopyMask",
|
| 126 |
+
"shader": "dropout.wgsl.jinja",
|
| 127 |
+
"bindings": [
|
| 128 |
+
{
|
| 129 |
+
"name": "x",
|
| 130 |
+
"arg": "x",
|
| 131 |
+
"semantic": "data",
|
| 132 |
+
"buffer": { "type": "read-only-storage" },
|
| 133 |
+
"elementType": "$scalar"
|
| 134 |
+
},
|
| 135 |
+
{ "name": "y", "arg": "y", "semantic": "output", "buffer": { "type": "storage" }, "elementType": "$scalar" },
|
| 136 |
+
{ "name": "mask", "arg": "mask", "semantic": "mask", "buffer": { "type": "storage" }, "elementType": "u32" },
|
| 137 |
+
{
|
| 138 |
+
"name": "params",
|
| 139 |
+
"semantic": "kernel.params",
|
| 140 |
+
"buffer": { "type": "uniform" },
|
| 141 |
+
"struct": {
|
| 142 |
+
"name": "Params",
|
| 143 |
+
"fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.output)" }]
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
],
|
| 147 |
+
"dispatch": { "threads": "numel(shapes.output)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
|
| 148 |
+
}
|
| 149 |
+
]
|
| 150 |
+
}
|
| 151 |
+
]
|
| 152 |
+
}
|
build/webgpu/metadata.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "ai.onnx.Dropout",
|
| 3 |
+
"id": "_ai_onnx_dropout_webgpu_1e25cf4",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"backend": { "type": "webgpu" },
|
| 7 |
+
"digest": {
|
| 8 |
+
"algorithm": "sha256",
|
| 9 |
+
"files": {
|
| 10 |
+
"bench.json": "eCAMPumj2uRsPQESWgHKb7zvrb8NiQIfIjsdGBlbO4E=",
|
| 11 |
+
"dropout-vec4.wgsl.jinja": "UVWQwKy05KoAgvytw7s8nJPWWp/ZSXA6RXQaIPgXfV8=",
|
| 12 |
+
"dropout.wgsl.jinja": "ihCug0ebE5xa6fNeVS9Tm6h/2ZwezWoYWGJJA73PDk4=",
|
| 13 |
+
"manifest.json": "v1+Jd5K6LUjgUKpgZy1z/a5x87dauFbr5+AOPRqwICo=",
|
| 14 |
+
"test.json": "GLjoVvpcDWihcNm/5FeGh5oevXyHsyc/NzyTvmqsyes="
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } },
|
| 18 |
+
"webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/ai.onnx.Dropout" }
|
| 19 |
+
}
|
build/webgpu/test.json
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"op": "ai.onnx.Dropout",
|
| 3 |
+
"fixtureArrays": {
|
| 4 |
+
"onnx_backend_input_x": [1.764052391052246, 0.40015721321105957, 0.978738009929657, 2.2408931255340576, 1.8675580024719238, -0.9772778749465942, 0.9500884413719177, -0.15135720372200012, -0.10321885347366333, 0.4105985164642334, 0.14404356479644775, 1.4542734622955322, 0.7610377073287964, 0.12167501449584961, 0.44386324286460876, 0.3336743414402008, 1.4940791130065918, -0.2051582634449005, 0.3130677044391632, -0.8540957570075989, -2.5529897212982178, 0.653618574142456, 0.8644362092018127, -0.7421650290489197, 2.269754648208618, -1.4543657302856445, 0.04575851559638977, -0.18718385696411133, 1.5327792167663574, 1.4693588018417358, 0.154947429895401, 0.37816253304481506, -0.8877857327461243, -1.980796456336975, -0.34791216254234314, 0.15634897351264954, 1.2302906513214111, 1.202379822731018, -0.38732680678367615, -0.302302747964859, -1.0485529899597168, -1.420017957687378, -1.7062702178955078, 1.950775384902954, -0.5096521973609924, -0.4380742907524109, -1.2527953386306763, 0.7774903774261475, -1.6138978004455566, -0.21274028718471527, -0.8954665660858154, 0.38690251111984253, -0.5108051300048828, -1.18063223361969, -0.02818222902715206, 0.4283318817615509, 0.06651721894741058, 0.30247190594673157, -0.6343221068382263, -0.3627411723136902]
|
| 5 |
+
},
|
| 6 |
+
"cases": [
|
| 7 |
+
{
|
| 8 |
+
"name": "float32_inference_copy",
|
| 9 |
+
"provenance": { "source": "onnxruntime/test/providers/cpu/nn/dropout_op_test.cc", "test": "Dropout.Opset10" },
|
| 10 |
+
"inputs": {
|
| 11 |
+
"x": { "dtype": "float32", "shape": [2, 2], "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 5.0] } }
|
| 12 |
+
},
|
| 13 |
+
"outputs": { "y": { "dtype": "float32", "shape": [2, 2] } }
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"name": "ort_opset7_float32_inference_copy",
|
| 17 |
+
"provenance": { "source": "onnxruntime/test/providers/cpu/nn/dropout_op_test.cc", "test": "Dropout.Opset7" },
|
| 18 |
+
"inputs": {
|
| 19 |
+
"x": { "dtype": "float32", "shape": [2, 2], "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0] } }
|
| 20 |
+
},
|
| 21 |
+
"outputs": { "y": { "dtype": "float32", "shape": [2, 2] } }
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"name": "ort_opset13_optional_bool_mask_exact",
|
| 25 |
+
"provenance": {
|
| 26 |
+
"source": "onnxruntime/test/providers/cpu/nn/dropout_op_test.cc",
|
| 27 |
+
"test": "Dropout.WithOptionalOutputOpset10",
|
| 28 |
+
"notes": "Same optional-mask behavior validated through the current-schema ORT path, but with the ONNX-native bool mask dtype."
|
| 29 |
+
},
|
| 30 |
+
"inputs": {
|
| 31 |
+
"x": { "dtype": "float32", "shape": [2, 2], "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 5.0] } }
|
| 32 |
+
},
|
| 33 |
+
"outputs": {
|
| 34 |
+
"y": { "dtype": "float32", "shape": [2, 2] },
|
| 35 |
+
"mask": { "dtype": "bool", "shape": [2, 2], "tolerance": 0 }
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"name": "float16_inference_copy",
|
| 40 |
+
"inputs": {
|
| 41 |
+
"x": { "dtype": "float16", "shape": [2, 2], "data": { "kind": "values", "values": [1.0, -2.0, 3.5, 5.0] } }
|
| 42 |
+
},
|
| 43 |
+
"outputs": { "y": { "dtype": "float16", "shape": [2, 2], "tolerance": 0.001 } }
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"name": "float32_scalar_inference_copy",
|
| 47 |
+
"inputs": { "x": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [-4.5] } } },
|
| 48 |
+
"outputs": { "y": { "dtype": "float32", "shape": [], "tolerance": 0.000001 } }
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"name": "float32_nan_and_infinity_copy",
|
| 52 |
+
"inputs": {
|
| 53 |
+
"x": {
|
| 54 |
+
"dtype": "float32",
|
| 55 |
+
"shape": [5],
|
| 56 |
+
"data": { "kind": "values", "values": ["NaN", "-Infinity", 0.0, "Infinity", 3.0] }
|
| 57 |
+
}
|
| 58 |
+
},
|
| 59 |
+
"outputs": { "y": { "dtype": "float32", "shape": [5], "tolerance": 0.000001, "allowNaN": true } }
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"name": "float16_zero_sized_copy",
|
| 63 |
+
"inputs": { "x": { "dtype": "float16", "shape": [2, 0, 3], "data": { "kind": "values", "values": [] } } },
|
| 64 |
+
"outputs": { "y": { "dtype": "float16", "shape": [2, 0, 3], "tolerance": 0.001 } }
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"name": "onnx_backend_default_rank3_copy",
|
| 68 |
+
"provenance": {
|
| 69 |
+
"source": "cmake/external/onnx/onnx/backend/test/data/node/test_dropout_default",
|
| 70 |
+
"notes": "Imports the inference-copy output; optional ratio/training-mode inputs and mask output are omitted by this framework variant. The legacy test_dropout_random_old vector projects to the same inference-only request."
|
| 71 |
+
},
|
| 72 |
+
"inputs": {
|
| 73 |
+
"x": {
|
| 74 |
+
"dtype": "float32",
|
| 75 |
+
"shape": [3, 4, 5],
|
| 76 |
+
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_input_x" } }
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"outputs": { "y": { "dtype": "float32", "shape": [3, 4, 5], "tolerance": 0.000001 } }
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"name": "onnx_backend_default_mask_rank3",
|
| 83 |
+
"provenance": {
|
| 84 |
+
"source": "cmake/external/onnx/onnx/backend/test/data/node/test_dropout_default_mask",
|
| 85 |
+
"notes": "Inference mode emits the all-true ONNX bool mask."
|
| 86 |
+
},
|
| 87 |
+
"inputs": {
|
| 88 |
+
"x": {
|
| 89 |
+
"dtype": "float32",
|
| 90 |
+
"shape": [3, 4, 5],
|
| 91 |
+
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_backend_input_x" } }
|
| 92 |
+
}
|
| 93 |
+
},
|
| 94 |
+
"outputs": {
|
| 95 |
+
"y": { "dtype": "float32", "shape": [3, 4, 5], "tolerance": 0.000001 },
|
| 96 |
+
"mask": { "dtype": "bool", "shape": [3, 4, 5], "tolerance": 0 }
|
| 97 |
+
}
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"name": "onnx_backend_default_old_copy",
|
| 101 |
+
"provenance": {
|
| 102 |
+
"source": "cmake/external/onnx/onnx/backend/test/data/node/test_dropout_default_old",
|
| 103 |
+
"notes": "Older-schema Dropout inference-copy fixture represented with the project inference-only variant."
|
| 104 |
+
},
|
| 105 |
+
"inputs": { "x": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [-1.0, 0.0, 1.0] } } },
|
| 106 |
+
"outputs": { "y": { "dtype": "float32", "shape": [3], "tolerance": 0.000001 } }
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"name": "f32_scalar_mask_path_non_aligned",
|
| 110 |
+
"inputs": {
|
| 111 |
+
"x": { "dtype": "float32", "shape": [5], "data": { "kind": "values", "values": [1.0, -2.0, 3.5, 0.0, -0.5] } }
|
| 112 |
+
},
|
| 113 |
+
"outputs": {
|
| 114 |
+
"y": { "dtype": "float32", "shape": [5], "tolerance": 0.000001 },
|
| 115 |
+
"mask": { "dtype": "bool", "shape": [5], "tolerance": 0 }
|
| 116 |
+
}
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"name": "f16_scalar_mask_path_numel3",
|
| 120 |
+
"inputs": { "x": { "dtype": "float16", "shape": [3], "data": { "kind": "values", "values": [1.0, -2.0, 3.5] } } },
|
| 121 |
+
"outputs": {
|
| 122 |
+
"y": { "dtype": "float16", "shape": [3], "tolerance": 0.001 },
|
| 123 |
+
"mask": { "dtype": "bool", "shape": [3], "tolerance": 0 }
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
]
|
| 127 |
+
}
|