sync 4385228f788d
Browse files- README.md +15 -10
- build/webgpu/bench.json +72 -18
- build/webgpu/causal-conv-with-state-tiled.wgsl.jinja +65 -27
- build/webgpu/causal-conv-with-state-vec4.wgsl.jinja +3 -2
- build/webgpu/causal-conv-with-state.wgsl.jinja +3 -2
- build/webgpu/manifest.json +1 -365
- build/webgpu/metadata.json +1 -36
- build/webgpu/test.json +46 -12
README.md
CHANGED
|
@@ -52,33 +52,38 @@ Default values (overridable per request):
|
|
| 52 |
|
| 53 |
## Files
|
| 54 |
|
| 55 |
-
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests,
|
| 56 |
-
- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
|
| 57 |
-
- [`test.json`](build/webgpu/test.json) — correctness cases
|
| 58 |
-
- [`bench.json`](build/webgpu/bench.json) — benchmark cases
|
| 59 |
-
- [`causal-conv-with-state-tiled.wgsl.jinja`](build/webgpu/causal-conv-with-state-tiled.wgsl.jinja)
|
| 60 |
-
- [`causal-conv-with-state-vec4.wgsl.jinja`](build/webgpu/causal-conv-with-state-vec4.wgsl.jinja)
|
| 61 |
-
- [`causal-conv-with-state.wgsl.jinja`](build/webgpu/causal-conv-with-state.wgsl.jinja)
|
| 62 |
|
| 63 |
## Use with `@huggingface/kernels`
|
| 64 |
|
| 65 |
```sh
|
| 66 |
-
npm install --save-exact @huggingface/kernels@0.0.1-preview.
|
| 67 |
```
|
| 68 |
|
|
|
|
|
|
|
| 69 |
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
|
| 70 |
|
| 71 |
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 72 |
It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
|
| 73 |
|
| 74 |
-
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
|
| 75 |
-
|
| 76 |
```js
|
| 77 |
import { getKernel } from "@huggingface/kernels";
|
| 78 |
|
| 79 |
const kernel = await getKernel("webgpu-kernels/com.microsoft.CausalConvWithState", { version: 1 });
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
const { outputT, presentStateT } = await kernel({
|
| 81 |
inputT: { data: inputTData, shape: [1, 1, 5] },
|
| 82 |
weightT: { data: weightTData, shape: [1, 1, 4] },
|
| 83 |
});
|
|
|
|
| 84 |
```
|
|
|
|
| 52 |
|
| 53 |
## Files
|
| 54 |
|
| 55 |
+
- [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.CausalConvWithState/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)
|
| 56 |
+
- [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.CausalConvWithState/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)
|
| 57 |
+
- [`test.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.CausalConvWithState/blob/v1/build/webgpu/test.json) — correctness cases
|
| 58 |
+
- [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.CausalConvWithState/blob/v1/build/webgpu/bench.json) — benchmark cases
|
| 59 |
+
- [`causal-conv-with-state-tiled.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.CausalConvWithState/blob/v1/build/webgpu/causal-conv-with-state-tiled.wgsl.jinja)
|
| 60 |
+
- [`causal-conv-with-state-vec4.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.CausalConvWithState/blob/v1/build/webgpu/causal-conv-with-state-vec4.wgsl.jinja)
|
| 61 |
+
- [`causal-conv-with-state.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.CausalConvWithState/blob/v1/build/webgpu/causal-conv-with-state.wgsl.jinja)
|
| 62 |
|
| 63 |
## Use with `@huggingface/kernels`
|
| 64 |
|
| 65 |
```sh
|
| 66 |
+
npm install --save-exact @huggingface/kernels@0.0.1-preview.4
|
| 67 |
```
|
| 68 |
|
| 69 |
+
Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.
|
| 70 |
+
|
| 71 |
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
|
| 72 |
|
| 73 |
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
|
| 74 |
It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
|
| 75 |
|
|
|
|
|
|
|
| 76 |
```js
|
| 77 |
import { getKernel } from "@huggingface/kernels";
|
| 78 |
|
| 79 |
const kernel = await getKernel("webgpu-kernels/com.microsoft.CausalConvWithState", { version: 1 });
|
| 80 |
+
|
| 81 |
+
const inputTData = Float32Array.of(1, 2, 3, 4, 5);
|
| 82 |
+
const weightTData = Float32Array.of(0.1, 0.2, 0.3, 0.4);
|
| 83 |
+
|
| 84 |
const { outputT, presentStateT } = await kernel({
|
| 85 |
inputT: { data: inputTData, shape: [1, 1, 5] },
|
| 86 |
weightT: { data: weightTData, shape: [1, 1, 4] },
|
| 87 |
});
|
| 88 |
+
console.log({ outputT, presentStateT });
|
| 89 |
```
|
build/webgpu/bench.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
"bench": {
|
| 18 |
"primary": true,
|
| 19 |
"metrics": [
|
| 20 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 21 |
{
|
| 22 |
"type": "bandwidth",
|
| 23 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -43,7 +43,7 @@
|
|
| 43 |
"bench": {
|
| 44 |
"primary": true,
|
| 45 |
"metrics": [
|
| 46 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 47 |
{
|
| 48 |
"type": "bandwidth",
|
| 49 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -68,7 +68,7 @@
|
|
| 68 |
"bench": {
|
| 69 |
"primary": true,
|
| 70 |
"metrics": [
|
| 71 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 72 |
{
|
| 73 |
"type": "bandwidth",
|
| 74 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -94,7 +94,7 @@
|
|
| 94 |
},
|
| 95 |
"bench": {
|
| 96 |
"metrics": [
|
| 97 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 98 |
{
|
| 99 |
"type": "bandwidth",
|
| 100 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -122,7 +122,7 @@
|
|
| 122 |
},
|
| 123 |
"bench": {
|
| 124 |
"metrics": [
|
| 125 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 126 |
{
|
| 127 |
"type": "bandwidth",
|
| 128 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -150,7 +150,7 @@
|
|
| 150 |
},
|
| 151 |
"bench": {
|
| 152 |
"metrics": [
|
| 153 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 154 |
{
|
| 155 |
"type": "bandwidth",
|
| 156 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -179,7 +179,7 @@
|
|
| 179 |
},
|
| 180 |
"bench": {
|
| 181 |
"metrics": [
|
| 182 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 183 |
{
|
| 184 |
"type": "bandwidth",
|
| 185 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -203,7 +203,7 @@
|
|
| 203 |
"bench": {
|
| 204 |
"primary": true,
|
| 205 |
"metrics": [
|
| 206 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 207 |
{
|
| 208 |
"type": "bandwidth",
|
| 209 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -227,7 +227,7 @@
|
|
| 227 |
},
|
| 228 |
"bench": {
|
| 229 |
"metrics": [
|
| 230 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 231 |
{
|
| 232 |
"type": "bandwidth",
|
| 233 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -255,7 +255,7 @@
|
|
| 255 |
},
|
| 256 |
"bench": {
|
| 257 |
"metrics": [
|
| 258 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT,
|
| 259 |
{
|
| 260 |
"type": "bandwidth",
|
| 261 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -281,7 +281,7 @@
|
|
| 281 |
},
|
| 282 |
"bench": {
|
| 283 |
"metrics": [
|
| 284 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT,
|
| 285 |
{
|
| 286 |
"type": "bandwidth",
|
| 287 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -309,7 +309,7 @@
|
|
| 309 |
},
|
| 310 |
"bench": {
|
| 311 |
"metrics": [
|
| 312 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT,
|
| 313 |
{
|
| 314 |
"type": "bandwidth",
|
| 315 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -335,7 +335,7 @@
|
|
| 335 |
},
|
| 336 |
"bench": {
|
| 337 |
"metrics": [
|
| 338 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT,
|
| 339 |
{
|
| 340 |
"type": "bandwidth",
|
| 341 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -363,7 +363,7 @@
|
|
| 363 |
},
|
| 364 |
"bench": {
|
| 365 |
"metrics": [
|
| 366 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT,
|
| 367 |
{
|
| 368 |
"type": "bandwidth",
|
| 369 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -389,7 +389,7 @@
|
|
| 389 |
},
|
| 390 |
"bench": {
|
| 391 |
"metrics": [
|
| 392 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT,
|
| 393 |
{
|
| 394 |
"type": "bandwidth",
|
| 395 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -413,7 +413,7 @@
|
|
| 413 |
"bench": {
|
| 414 |
"primary": true,
|
| 415 |
"metrics": [
|
| 416 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 417 |
{
|
| 418 |
"type": "bandwidth",
|
| 419 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -437,7 +437,7 @@
|
|
| 437 |
"bench": {
|
| 438 |
"primary": true,
|
| 439 |
"metrics": [
|
| 440 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 441 |
{
|
| 442 |
"type": "bandwidth",
|
| 443 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
@@ -461,13 +461,67 @@
|
|
| 461 |
"bench": {
|
| 462 |
"primary": true,
|
| 463 |
"metrics": [
|
| 464 |
-
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, 1)" },
|
| 465 |
{
|
| 466 |
"type": "bandwidth",
|
| 467 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
| 468 |
}
|
| 469 |
]
|
| 470 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
}
|
| 472 |
]
|
| 473 |
}
|
|
|
|
| 17 |
"bench": {
|
| 18 |
"primary": true,
|
| 19 |
"metrics": [
|
| 20 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 21 |
{
|
| 22 |
"type": "bandwidth",
|
| 23 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 43 |
"bench": {
|
| 44 |
"primary": true,
|
| 45 |
"metrics": [
|
| 46 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 47 |
{
|
| 48 |
"type": "bandwidth",
|
| 49 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 68 |
"bench": {
|
| 69 |
"primary": true,
|
| 70 |
"metrics": [
|
| 71 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 72 |
{
|
| 73 |
"type": "bandwidth",
|
| 74 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 94 |
},
|
| 95 |
"bench": {
|
| 96 |
"metrics": [
|
| 97 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 98 |
{
|
| 99 |
"type": "bandwidth",
|
| 100 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 122 |
},
|
| 123 |
"bench": {
|
| 124 |
"metrics": [
|
| 125 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 126 |
{
|
| 127 |
"type": "bandwidth",
|
| 128 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 150 |
},
|
| 151 |
"bench": {
|
| 152 |
"metrics": [
|
| 153 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 154 |
{
|
| 155 |
"type": "bandwidth",
|
| 156 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 179 |
},
|
| 180 |
"bench": {
|
| 181 |
"metrics": [
|
| 182 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 183 |
{
|
| 184 |
"type": "bandwidth",
|
| 185 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 203 |
"bench": {
|
| 204 |
"primary": true,
|
| 205 |
"metrics": [
|
| 206 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 207 |
{
|
| 208 |
"type": "bandwidth",
|
| 209 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 227 |
},
|
| 228 |
"bench": {
|
| 229 |
"metrics": [
|
| 230 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 231 |
{
|
| 232 |
"type": "bandwidth",
|
| 233 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 255 |
},
|
| 256 |
"bench": {
|
| 257 |
"metrics": [
|
| 258 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 259 |
{
|
| 260 |
"type": "bandwidth",
|
| 261 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 281 |
},
|
| 282 |
"bench": {
|
| 283 |
"metrics": [
|
| 284 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 285 |
{
|
| 286 |
"type": "bandwidth",
|
| 287 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 309 |
},
|
| 310 |
"bench": {
|
| 311 |
"metrics": [
|
| 312 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 313 |
{
|
| 314 |
"type": "bandwidth",
|
| 315 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 335 |
},
|
| 336 |
"bench": {
|
| 337 |
"metrics": [
|
| 338 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 339 |
{
|
| 340 |
"type": "bandwidth",
|
| 341 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 363 |
},
|
| 364 |
"bench": {
|
| 365 |
"metrics": [
|
| 366 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 367 |
{
|
| 368 |
"type": "bandwidth",
|
| 369 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 389 |
},
|
| 390 |
"bench": {
|
| 391 |
"metrics": [
|
| 392 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 393 |
{
|
| 394 |
"type": "bandwidth",
|
| 395 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.biasT) + numel(shapes.pastStateT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 413 |
"bench": {
|
| 414 |
"primary": true,
|
| 415 |
"metrics": [
|
| 416 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 417 |
{
|
| 418 |
"type": "bandwidth",
|
| 419 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 437 |
"bench": {
|
| 438 |
"primary": true,
|
| 439 |
"metrics": [
|
| 440 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 441 |
{
|
| 442 |
"type": "bandwidth",
|
| 443 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
|
|
|
| 461 |
"bench": {
|
| 462 |
"primary": true,
|
| 463 |
"metrics": [
|
| 464 |
+
{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" },
|
| 465 |
{
|
| 466 |
"type": "bandwidth",
|
| 467 |
"value": "(numel(shapes.inputT) + numel(shapes.weightT) + numel(shapes.outputT) + numel(shapes.presentStateT)) * 4"
|
| 468 |
}
|
| 469 |
]
|
| 470 |
}
|
| 471 |
+
},
|
| 472 |
+
{
|
| 473 |
+
"name": "prefill-b2c192t256-k33-f32",
|
| 474 |
+
"preset": "stress",
|
| 475 |
+
"tunableSpace": { "tiledWorkgroupSize": [64, 128, 256] },
|
| 476 |
+
"vars": { "batch": 2, "channels": 192, "length": 256, "kernel": 33 },
|
| 477 |
+
"attrs": { "activation": "none" },
|
| 478 |
+
"inputs": {
|
| 479 |
+
"inputT": { "shape": [2, 192, 256], "dtype": "float32", "dist": "normal", "seed": 301, "scale": 0.2 },
|
| 480 |
+
"weightT": { "shape": [192, 1, 33], "dtype": "float32", "dist": "normal", "seed": 302, "scale": 0.05 }
|
| 481 |
+
},
|
| 482 |
+
"outputs": {
|
| 483 |
+
"outputT": { "shape": [2, 192, 256], "dtype": "float32", "dist": "empty" },
|
| 484 |
+
"presentStateT": { "shape": [2, 192, 32], "dtype": "float32", "dist": "empty" }
|
| 485 |
+
},
|
| 486 |
+
"bench": {
|
| 487 |
+
"metrics": [{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" }]
|
| 488 |
+
}
|
| 489 |
+
},
|
| 490 |
+
{
|
| 491 |
+
"name": "prefill-b1c384t1024-k65-f32",
|
| 492 |
+
"preset": "stress",
|
| 493 |
+
"tunableSpace": { "tiledWorkgroupSize": [64, 128, 256] },
|
| 494 |
+
"vars": { "batch": 1, "channels": 384, "length": 1024, "kernel": 65 },
|
| 495 |
+
"attrs": { "activation": "none" },
|
| 496 |
+
"inputs": {
|
| 497 |
+
"inputT": { "shape": [1, 384, 1024], "dtype": "float32", "dist": "normal", "seed": 301, "scale": 0.2 },
|
| 498 |
+
"weightT": { "shape": [384, 1, 65], "dtype": "float32", "dist": "normal", "seed": 302, "scale": 0.05 }
|
| 499 |
+
},
|
| 500 |
+
"outputs": {
|
| 501 |
+
"outputT": { "shape": [1, 384, 1024], "dtype": "float32", "dist": "empty" },
|
| 502 |
+
"presentStateT": { "shape": [1, 384, 64], "dtype": "float32", "dist": "empty" }
|
| 503 |
+
},
|
| 504 |
+
"bench": {
|
| 505 |
+
"metrics": [{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" }]
|
| 506 |
+
}
|
| 507 |
+
},
|
| 508 |
+
{
|
| 509 |
+
"name": "prefill-b2c256t512-k64-f16",
|
| 510 |
+
"preset": "stress",
|
| 511 |
+
"tunableSpace": { "tiledWorkgroupSize": [64, 128, 256] },
|
| 512 |
+
"vars": { "batch": 2, "channels": 256, "length": 512, "kernel": 64 },
|
| 513 |
+
"attrs": { "activation": "none" },
|
| 514 |
+
"inputs": {
|
| 515 |
+
"inputT": { "shape": [2, 256, 512], "dtype": "float16", "dist": "normal", "seed": 301, "scale": 0.2 },
|
| 516 |
+
"weightT": { "shape": [256, 1, 64], "dtype": "float16", "dist": "normal", "seed": 302, "scale": 0.05 }
|
| 517 |
+
},
|
| 518 |
+
"outputs": {
|
| 519 |
+
"outputT": { "shape": [2, 256, 512], "dtype": "float16", "dist": "empty" },
|
| 520 |
+
"presentStateT": { "shape": [2, 256, 63], "dtype": "float16", "dist": "empty" }
|
| 521 |
+
},
|
| 522 |
+
"bench": {
|
| 523 |
+
"metrics": [{ "type": "gflops", "value": "2 * numel(shapes.outputT) * dim(shapes.weightT, ranks.weightT - 1)" }]
|
| 524 |
+
}
|
| 525 |
}
|
| 526 |
]
|
| 527 |
}
|
build/webgpu/causal-conv-with-state-tiled.wgsl.jinja
CHANGED
|
@@ -1,21 +1,25 @@
|
|
| 1 |
{% set pastSlot = "(params.stateWindow - 1u) * params.stateSlotStride + " if hasStateWindow else "" %}
|
|
|
|
| 2 |
{{ env.wgsl.resourceDeclarations }}
|
| 3 |
|
| 4 |
const WG: u32 = {{ workgroupSize }}u;
|
| 5 |
const TILE: u32 = {{ tileSize }}u;
|
| 6 |
const OUTPUTS_PER_THREAD: u32 = 8u;
|
| 7 |
const KERNEL_SIZE: u32 = {{ kernelSize }}u;
|
| 8 |
-
//
|
| 9 |
-
// to a multiple of four and zero-filling the tail lets a kernel of any length
|
| 10 |
-
// use it: the phantom taps contribute nothing. The input tile grows to match,
|
| 11 |
-
// because the last lane reads TILE + KERNEL_PADDED - 2.
|
| 12 |
const KERNEL_PADDED: u32 = {{ kernelSizePadded }}u;
|
| 13 |
const STATE_LENGTH: u32 = {% if causalDilation is defined and causalDilation != 1 %}(KERNEL_SIZE - 1u) * {{ causalDilation }}u{% else %}KERNEL_SIZE - 1u{% endif %};
|
| 14 |
const INPUT_TILE_SIZE: u32 = {% if causalDilation is defined and causalDilation != 1 %}TILE + (KERNEL_PADDED - 1u) * {{ causalDilation }}u{% else %}TILE + KERNEL_PADDED - 1u{% endif %};
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
var<workgroup> input_tile: array<f32, {{ inputTileSize }}>;
|
| 17 |
var<workgroup> weight_tile: array<f32, {{ kernelSizePadded }}>;
|
| 18 |
|
|
|
|
| 19 |
fn activate(value: f32) -> f32 {
|
| 20 |
{% if useSilu %}
|
| 21 |
return value / (1.0 + exp(-value));
|
|
@@ -41,6 +45,28 @@ fn main(@builtin(local_invocation_id) lid3: vec3<u32>,
|
|
| 41 |
let channel = bc % params.channels;
|
| 42 |
let tile_start = tile_index * TILE;
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
var i = lane;
|
| 45 |
while (i < INPUT_TILE_SIZE) {
|
| 46 |
// input_tile[i] is the concatenated state/input sample needed at output
|
|
@@ -70,6 +96,7 @@ fn main(@builtin(local_invocation_id) lid3: vec3<u32>,
|
|
| 70 |
weight_tile[i] = weight_value;
|
| 71 |
i = i + WG;
|
| 72 |
}
|
|
|
|
| 73 |
workgroupBarrier();
|
| 74 |
|
| 75 |
let pos = tile_start + lane * OUTPUTS_PER_THREAD;
|
|
@@ -81,6 +108,31 @@ fn main(@builtin(local_invocation_id) lid3: vec3<u32>,
|
|
| 81 |
var acc0 = vec4<f32>(0.0);
|
| 82 |
var acc1 = vec4<f32>(0.0);
|
| 83 |
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
// Each lane computes eight adjacent outputs and reuses a weight across them.
|
| 85 |
var k = 0u;
|
| 86 |
while (k < KERNEL_PADDED) {
|
|
@@ -90,30 +142,16 @@ fn main(@builtin(local_invocation_id) lid3: vec3<u32>,
|
|
| 90 |
weight_tile[k + 2u],
|
| 91 |
weight_tile[k + 3u]
|
| 92 |
);
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
{%
|
| 97 |
-
{%
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
let x02 = vec4<f32>(input_tile[base0 + 2u], input_tile[base0 + 3u], input_tile[base0 + 4u], input_tile[base0 + 5u]);
|
| 102 |
-
let x03 = vec4<f32>(input_tile[base0 + 3u], input_tile[base0 + 4u], input_tile[base0 + 5u], input_tile[base0 + 6u]);
|
| 103 |
-
let x10 = vec4<f32>(input_tile[base1], input_tile[base1 + 1u], input_tile[base1 + 2u], input_tile[base1 + 3u]);
|
| 104 |
-
let x11 = vec4<f32>(input_tile[base1 + 1u], input_tile[base1 + 2u], input_tile[base1 + 3u], input_tile[base1 + 4u]);
|
| 105 |
-
let x12 = vec4<f32>(input_tile[base1 + 2u], input_tile[base1 + 3u], input_tile[base1 + 4u], input_tile[base1 + 5u]);
|
| 106 |
-
let x13 = vec4<f32>(input_tile[base1 + 3u], input_tile[base1 + 4u], input_tile[base1 + 5u], input_tile[base1 + 6u]);
|
| 107 |
-
{% endif %} acc0 = fma(x00, vec4<f32>(w.x), acc0);
|
| 108 |
-
acc0 = fma(x01, vec4<f32>(w.y), acc0);
|
| 109 |
-
acc0 = fma(x02, vec4<f32>(w.z), acc0);
|
| 110 |
-
acc0 = fma(x03, vec4<f32>(w.w), acc0);
|
| 111 |
-
acc1 = fma(x10, vec4<f32>(w.x), acc1);
|
| 112 |
-
acc1 = fma(x11, vec4<f32>(w.y), acc1);
|
| 113 |
-
acc1 = fma(x12, vec4<f32>(w.z), acc1);
|
| 114 |
-
acc1 = fma(x13, vec4<f32>(w.w), acc1);
|
| 115 |
-
k = k + 4u;
|
| 116 |
}
|
|
|
|
| 117 |
let output_base = bc * params.length + pos;
|
| 118 |
output[output_base] = {{ outputScalar }}(activate(acc0.x));
|
| 119 |
output[output_base + 1u] = {{ outputScalar }}(activate(acc0.y));
|
|
|
|
| 1 |
{% set pastSlot = "(params.stateWindow - 1u) * params.stateSlotStride + " if hasStateWindow else "" %}
|
| 2 |
+
{% set dilation = causalDilation | default(1) %}
|
| 3 |
{{ env.wgsl.resourceDeclarations }}
|
| 4 |
|
| 5 |
const WG: u32 = {{ workgroupSize }}u;
|
| 6 |
const TILE: u32 = {{ tileSize }}u;
|
| 7 |
const OUTPUTS_PER_THREAD: u32 = 8u;
|
| 8 |
const KERNEL_SIZE: u32 = {{ kernelSize }}u;
|
| 9 |
+
// Stage complete words. Only the real taps participate in the convolution.
|
|
|
|
|
|
|
|
|
|
| 10 |
const KERNEL_PADDED: u32 = {{ kernelSizePadded }}u;
|
| 11 |
const STATE_LENGTH: u32 = {% if causalDilation is defined and causalDilation != 1 %}(KERNEL_SIZE - 1u) * {{ causalDilation }}u{% else %}KERNEL_SIZE - 1u{% endif %};
|
| 12 |
const INPUT_TILE_SIZE: u32 = {% if causalDilation is defined and causalDilation != 1 %}TILE + (KERNEL_PADDED - 1u) * {{ causalDilation }}u{% else %}TILE + KERNEL_PADDED - 1u{% endif %};
|
| 13 |
|
| 14 |
+
{% if packedWindow %}
|
| 15 |
+
var<workgroup> input_words: array<vec4<f32>, {{ ceilDiv(inputTileSize, 4) }}>;
|
| 16 |
+
var<workgroup> weight_words: array<vec4<f32>, {{ kernelSizePadded // 4 }}>;
|
| 17 |
+
|
| 18 |
+
{% else %}
|
| 19 |
var<workgroup> input_tile: array<f32, {{ inputTileSize }}>;
|
| 20 |
var<workgroup> weight_tile: array<f32, {{ kernelSizePadded }}>;
|
| 21 |
|
| 22 |
+
{% endif %}
|
| 23 |
fn activate(value: f32) -> f32 {
|
| 24 |
{% if useSilu %}
|
| 25 |
return value / (1.0 + exp(-value));
|
|
|
|
| 45 |
let channel = bc % params.channels;
|
| 46 |
let tile_start = tile_index * TILE;
|
| 47 |
|
| 48 |
+
{% if packedWindow %}
|
| 49 |
+
for (var i = lane; i < (INPUT_TILE_SIZE + 3u) / 4u; i += WG) {
|
| 50 |
+
var word = vec4<f32>(0.0);
|
| 51 |
+
for (var j = 0u; j < 4u; j++) {
|
| 52 |
+
let virtualPos = tile_start + 4u * i + j;
|
| 53 |
+
if (virtualPos >= STATE_LENGTH) {
|
| 54 |
+
let position = virtualPos - STATE_LENGTH;
|
| 55 |
+
if (position < params.length) { word[j] = f32(input[bc * params.length + position]); }
|
| 56 |
+
}{% if hasState %} else {
|
| 57 |
+
word[j] = f32(past_state[{{ pastSlot }}bc * STATE_LENGTH + virtualPos]);
|
| 58 |
+
}{% endif %}
|
| 59 |
+
}
|
| 60 |
+
input_words[i] = word;
|
| 61 |
+
}
|
| 62 |
+
for (var i = lane; i < KERNEL_PADDED / 4u; i += WG) {
|
| 63 |
+
var word = vec4<f32>(0.0);
|
| 64 |
+
for (var j = 0u; j < 4u; j++) {
|
| 65 |
+
if (4u * i + j < KERNEL_SIZE) { word[j] = f32(weight[channel * KERNEL_SIZE + 4u * i + j]); }
|
| 66 |
+
}
|
| 67 |
+
weight_words[i] = word;
|
| 68 |
+
}
|
| 69 |
+
{% else %}
|
| 70 |
var i = lane;
|
| 71 |
while (i < INPUT_TILE_SIZE) {
|
| 72 |
// input_tile[i] is the concatenated state/input sample needed at output
|
|
|
|
| 96 |
weight_tile[i] = weight_value;
|
| 97 |
i = i + WG;
|
| 98 |
}
|
| 99 |
+
{% endif %}
|
| 100 |
workgroupBarrier();
|
| 101 |
|
| 102 |
let pos = tile_start + lane * OUTPUTS_PER_THREAD;
|
|
|
|
| 108 |
var acc0 = vec4<f32>(0.0);
|
| 109 |
var acc1 = vec4<f32>(0.0);
|
| 110 |
{% endif %}
|
| 111 |
+
{% if packedWindow %}
|
| 112 |
+
var left = input_words[2u * lane];
|
| 113 |
+
var middle = input_words[2u * lane + 1u];
|
| 114 |
+
{% macro step(taps, offset) %}
|
| 115 |
+
{% if taps > 1 %}let right = input_words[2u * lane + {{ offset }} + 2u];
|
| 116 |
+
{% endif %}
|
| 117 |
+
let w = weight_words[{{ offset }}];
|
| 118 |
+
acc0 = fma(left, vec4<f32>(w.x), acc0);
|
| 119 |
+
acc1 = fma(middle, vec4<f32>(w.x), acc1);
|
| 120 |
+
{% if taps >= 2 %}acc0 = fma(vec4<f32>(left.yzw, middle.x), vec4<f32>(w.y), acc0);
|
| 121 |
+
acc1 = fma(vec4<f32>(middle.yzw, right.x), vec4<f32>(w.y), acc1);
|
| 122 |
+
{% endif %}{% if taps >= 3 %}acc0 = fma(vec4<f32>(left.zw, middle.xy), vec4<f32>(w.z), acc0);
|
| 123 |
+
acc1 = fma(vec4<f32>(middle.zw, right.xy), vec4<f32>(w.z), acc1);
|
| 124 |
+
{% endif %}{% if taps >= 4 %}acc0 = fma(vec4<f32>(left.w, middle.xyz), vec4<f32>(w.w), acc0);
|
| 125 |
+
acc1 = fma(vec4<f32>(middle.w, right.xyz), vec4<f32>(w.w), acc1);
|
| 126 |
+
{% endif %}{% endmacro %}
|
| 127 |
+
for (var k = 0u; k < {{ kernelSize // 4 }}u; k++) {
|
| 128 |
+
{{ step(4,"k") }}
|
| 129 |
+
left = middle;
|
| 130 |
+
middle = right;
|
| 131 |
+
}
|
| 132 |
+
{% if kernelSize % 4 != 0 %}{
|
| 133 |
+
{{ step(kernelSize % 4, (kernelSize // 4) ~ "u") }}
|
| 134 |
+
}
|
| 135 |
+
{% endif %}{% else %}
|
| 136 |
// Each lane computes eight adjacent outputs and reuses a weight across them.
|
| 137 |
var k = 0u;
|
| 138 |
while (k < KERNEL_PADDED) {
|
|
|
|
| 142 |
weight_tile[k + 2u],
|
| 143 |
weight_tile[k + 3u]
|
| 144 |
);
|
| 145 |
+
let base = lane * OUTPUTS_PER_THREAD + k * {{ dilation }}u;
|
| 146 |
+
{% for block in range(2) %}{% for tap in range(4) %}
|
| 147 |
+
{% set guard = kernelSize % 4 != 0 and tap >= kernelSize % 4 %}
|
| 148 |
+
{% if guard %} if (k + {{ tap }}u < KERNEL_SIZE) {
|
| 149 |
+
{% endif %} let x{{ block }}{{ tap }} = vec4<f32>({% for i in range(4) %}{{ ", " if not loop.first else "" }}input_tile[base + {{ block * 4 + tap * dilation + i }}u]{% endfor %});
|
| 150 |
+
acc{{ block }} = fma(x{{ block }}{{ tap }}, vec4<f32>(w.{{ "xyzw"[tap] }}), acc{{ block }});
|
| 151 |
+
{% if guard %} }
|
| 152 |
+
{% endif %}{% endfor %}{% endfor %} k = k + 4u;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
}
|
| 154 |
+
{% endif %}
|
| 155 |
let output_base = bc * params.length + pos;
|
| 156 |
output[output_base] = {{ outputScalar }}(activate(acc0.x));
|
| 157 |
output[output_base + 1u] = {{ outputScalar }}(activate(acc0.y));
|
build/webgpu/causal-conv-with-state-vec4.wgsl.jinja
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
{% set pastSlot = "(params.stateWindow - 1u) * params.stateSlotStride + " if hasStateWindow else "" %}
|
| 2 |
-
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count"
|
| 3 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 4 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 5 |
// per-axis workgroup fold width.
|
| 6 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 7 |
if ({{ name }} >= {{ bound }}) {
|
| 8 |
return;
|
| 9 |
-
}
|
|
|
|
| 10 |
{{ env.wgsl.resourceDeclarations }}
|
| 11 |
|
| 12 |
// Four outputs per invocation for a kernel narrow enough that every tap of a
|
|
|
|
| 1 |
{% set pastSlot = "(params.stateWindow - 1u) * params.stateSlotStride + " if hasStateWindow else "" %}
|
| 2 |
+
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count") %}
|
| 3 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 4 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 5 |
// per-axis workgroup fold width.
|
| 6 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 7 |
if ({{ name }} >= {{ bound }}) {
|
| 8 |
return;
|
| 9 |
+
}
|
| 10 |
+
{% endmacro %}
|
| 11 |
{{ env.wgsl.resourceDeclarations }}
|
| 12 |
|
| 13 |
// Four outputs per invocation for a kernel narrow enough that every tap of a
|
build/webgpu/causal-conv-with-state.wgsl.jinja
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
{% set pastSlot = "(params.stateWindow - 1u) * params.stateSlotStride + " if hasStateWindow else "" %}
|
| 2 |
-
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count"
|
| 3 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 4 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 5 |
// per-axis workgroup fold width.
|
| 6 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 7 |
if ({{ name }} >= {{ bound }}) {
|
| 8 |
return;
|
| 9 |
-
}
|
|
|
|
| 10 |
{{ env.wgsl.resourceDeclarations }}
|
| 11 |
|
| 12 |
const WG: u32 = {{ workgroupSize }}u;
|
|
|
|
| 1 |
{% set pastSlot = "(params.stateWindow - 1u) * params.stateSlotStride + " if hasStateWindow else "" %}
|
| 2 |
+
{% macro flat_index_2d(workgroupSize, name="i", bound="params.count") %}
|
| 3 |
{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}
|
| 4 |
// 2D-folded flat index: gid.y carries the high bits past the dispatch's
|
| 5 |
// per-axis workgroup fold width.
|
| 6 |
let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};
|
| 7 |
if ({{ name }} >= {{ bound }}) {
|
| 8 |
return;
|
| 9 |
+
}
|
| 10 |
+
{% endmacro %}
|
| 11 |
{{ env.wgsl.resourceDeclarations }}
|
| 12 |
|
| 13 |
const WG: u32 = {{ workgroupSize }}u;
|
build/webgpu/manifest.json
CHANGED
|
@@ -1,365 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"domain": "com.microsoft",
|
| 3 |
-
"name": "CausalConvWithState",
|
| 4 |
-
"sinceVersion": 1,
|
| 5 |
-
"inputs": {
|
| 6 |
-
"inputT": { "onnx": "input", "dtype": "T", "rank": 3 },
|
| 7 |
-
"weightT": { "onnx": "weight", "dtype": "T", "rank": 3 },
|
| 8 |
-
"biasT": { "onnx": "bias", "dtype": "T", "rank": 1, "optional": true },
|
| 9 |
-
"pastStateT": {
|
| 10 |
-
"onnx": "past_state",
|
| 11 |
-
"dtype": "T",
|
| 12 |
-
"rank": "3 if attrs.state_window == 0 else 4",
|
| 13 |
-
"optional": true
|
| 14 |
-
}
|
| 15 |
-
},
|
| 16 |
-
"outputs": {
|
| 17 |
-
"outputT": { "onnx": "output", "dtype": "T", "rank": 3, "shape": "shapes.inputT" },
|
| 18 |
-
"presentStateT": {
|
| 19 |
-
"onnx": "present_state",
|
| 20 |
-
"dtype": "T",
|
| 21 |
-
"rank": "3 if attrs.state_window == 0 else 4",
|
| 22 |
-
"shape": "([stateWindow] + stateShape) if windowed else stateShape"
|
| 23 |
-
}
|
| 24 |
-
},
|
| 25 |
-
"attributes": {
|
| 26 |
-
"activation": { "default": "none" },
|
| 27 |
-
"channels_last": { "default": 0 },
|
| 28 |
-
"dilation": { "default": 1 },
|
| 29 |
-
"ndim": { "default": 1 },
|
| 30 |
-
"state_window": { "default": 0 }
|
| 31 |
-
},
|
| 32 |
-
"attributeConstraints": {
|
| 33 |
-
"activation": { "values": ["none", "silu", "swish"] },
|
| 34 |
-
"channels_last": { "values": [0, 1] },
|
| 35 |
-
"ndim": { "values": [1] }
|
| 36 |
-
},
|
| 37 |
-
"typeConstraints": { "T": ["float32", "float16"] },
|
| 38 |
-
"tunables": { "workgroupSize": { "default": 256 }, "tiledWorkgroupSize": { "default": 128 } },
|
| 39 |
-
"derive": {
|
| 40 |
-
"channels": "dim(shapes.inputT, 2 if attrs.channels_last == 1 else 1)",
|
| 41 |
-
"inputLength": "dim(shapes.inputT, 1 if attrs.channels_last == 1 else 2)",
|
| 42 |
-
"causalDilation": "attrs.dilation",
|
| 43 |
-
"channelsLast": "attrs.channels_last == 1",
|
| 44 |
-
"stateWindow": "attrs.state_window",
|
| 45 |
-
"windowed": "stateWindow > 0",
|
| 46 |
-
"stateWindowOk": "stateWindow >= 0 and stateWindow <= 8",
|
| 47 |
-
"kernelSize": "dim(shapes.weightT, ranks.weightT - 1)",
|
| 48 |
-
"kernelSizePadded": "ceilDiv(kernelSize, 4) * 4",
|
| 49 |
-
"weightRankOk": "ranks.weightT == 3 and dim(shapes.weightT, 1) == 1",
|
| 50 |
-
"stateLength": "(kernelSize - 1) * causalDilation",
|
| 51 |
-
"stateSlotStride": "dim(shapes.inputT, 0) * channels * stateLength",
|
| 52 |
-
"windowedLengthOk": "not windowed or inputLength > 0",
|
| 53 |
-
"stateShape": "[dim(shapes.inputT, 0), stateLength, channels] if channelsLast else [dim(shapes.inputT, 0), channels, stateLength]",
|
| 54 |
-
"presentStateOk": "sameShape(shapes.presentStateT, ([stateWindow] + stateShape) if windowed else stateShape)",
|
| 55 |
-
"pastStateShapeOk": "present.pastStateT and sameShape(shapes.pastStateT, ([stateWindow] + stateShape) if windowed else stateShape)",
|
| 56 |
-
"commonContract": "ranks.inputT == 3 and weightRankOk and ranks.outputT == 3 and (tensorDtypes.inputT == \"float32\" or tensorDtypes.inputT == \"float16\") and tensorDtypes.weightT == tensorDtypes.inputT and tensorDtypes.outputT == tensorDtypes.inputT and tensorDtypes.presentStateT == tensorDtypes.inputT and f16Ok(dtypes.T) and channels == dim(shapes.weightT, 0) and sameShape(shapes.outputT, shapes.inputT) and stateWindowOk and windowedLengthOk and presentStateOk and kernelSize >= 1 and causalDilation >= 1 and floor(causalDilation) == causalDilation",
|
| 57 |
-
"zeroStateContract": "commonContract and not present.pastStateT and not present.biasT",
|
| 58 |
-
"biasNoStateContract": "commonContract and not present.pastStateT and present.biasT and ranks.biasT == 1 and tensorDtypes.biasT == tensorDtypes.inputT and dim(shapes.biasT, 0) == channels",
|
| 59 |
-
"stateNoBiasContract": "commonContract and present.pastStateT and not present.biasT and tensorDtypes.pastStateT == tensorDtypes.inputT and pastStateShapeOk",
|
| 60 |
-
"stateBiasContract": "commonContract and present.pastStateT and present.biasT and ranks.biasT == 1 and tensorDtypes.pastStateT == tensorDtypes.inputT and tensorDtypes.biasT == tensorDtypes.inputT and pastStateShapeOk and dim(shapes.biasT, 0) == channels",
|
| 61 |
-
"useSilu": "attrs.activation == \"silu\" or attrs.activation == \"swish\"",
|
| 62 |
-
"inputScalar": "dtypes.T",
|
| 63 |
-
"outputScalar": "dtypes.T",
|
| 64 |
-
"hasStateWindow": "windowed",
|
| 65 |
-
"hasBias": "present.biasT",
|
| 66 |
-
"hasState": "present.pastStateT"
|
| 67 |
-
},
|
| 68 |
-
"bindings": {
|
| 69 |
-
"input": { "arg": "inputT", "elementType": "$inputVec4" },
|
| 70 |
-
"weight": { "arg": "weightT", "elementType": "$weightElem" },
|
| 71 |
-
"output": { "arg": "outputT", "elementType": "$outputVec4" },
|
| 72 |
-
"present_state": { "arg": "presentStateT", "elementType": "$outputScalar" },
|
| 73 |
-
"params": {
|
| 74 |
-
"struct": [
|
| 75 |
-
{ "name": "batchSize", "type": "u32", "value": "dim(shapes.inputT, 0)" },
|
| 76 |
-
{ "name": "channels", "type": "u32", "value": "channels" },
|
| 77 |
-
{ "name": "length", "type": "u32", "value": "inputLength" },
|
| 78 |
-
{ "name": "stateWindow", "type": "u32", "value": "stateWindow" },
|
| 79 |
-
{ "name": "stateSlotStride", "type": "u32", "value": "stateSlotStride" }
|
| 80 |
-
]
|
| 81 |
-
},
|
| 82 |
-
"bias": { "arg": "biasT", "elementType": "$inputScalar" },
|
| 83 |
-
"past_state": { "arg": "pastStateT", "elementType": "$inputScalar" },
|
| 84 |
-
"input_main": { "arg": "inputT", "name": "input", "elementType": "$inputScalar" },
|
| 85 |
-
"weight_main": { "arg": "weightT", "name": "weight", "elementType": "$inputScalar" },
|
| 86 |
-
"output_main": { "arg": "outputT", "name": "output", "elementType": "$outputScalar" },
|
| 87 |
-
"params_main": {
|
| 88 |
-
"name": "params",
|
| 89 |
-
"struct": [
|
| 90 |
-
{ "name": "batchSize", "type": "u32", "value": "dim(shapes.inputT, 0)" },
|
| 91 |
-
{ "name": "channels", "type": "u32", "value": "channels" },
|
| 92 |
-
{ "name": "length", "type": "u32", "value": "inputLength" },
|
| 93 |
-
{ "name": "kernelSize", "type": "u32", "value": "kernelSize" },
|
| 94 |
-
{ "name": "stateWindow", "type": "u32", "value": "stateWindow" },
|
| 95 |
-
{ "name": "stateSlotStride", "type": "u32", "value": "stateSlotStride" }
|
| 96 |
-
]
|
| 97 |
-
}
|
| 98 |
-
},
|
| 99 |
-
"variants": [
|
| 100 |
-
{
|
| 101 |
-
"id": "zero_state_vec4",
|
| 102 |
-
"priority": 20,
|
| 103 |
-
"when": ["zeroStateContract", "kernelSize >= 2", "kernelSize <= 4", "dim(shapes.inputT, 2) >= 4", "dim(shapes.inputT, 2) % 4 == 0", "not channelsLast", "causalDilation == 1"],
|
| 104 |
-
"derive": {
|
| 105 |
-
"workgroupSize": 256,
|
| 106 |
-
"inputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 107 |
-
"outputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 108 |
-
"weightElem": "(\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\") if kernelSize == 4 else dtypes.T"
|
| 109 |
-
},
|
| 110 |
-
"passes": [
|
| 111 |
-
{
|
| 112 |
-
"id": "main",
|
| 113 |
-
"name": "CausalConvWithState.Vec4",
|
| 114 |
-
"shader": "causal-conv-with-state-vec4.wgsl.jinja",
|
| 115 |
-
"bindings": ["input", "weight", "output", "present_state", "params"],
|
| 116 |
-
"dispatch": {
|
| 117 |
-
"x": "min(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 118 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 119 |
-
"z": 1
|
| 120 |
-
}
|
| 121 |
-
}
|
| 122 |
-
]
|
| 123 |
-
},
|
| 124 |
-
{
|
| 125 |
-
"id": "zero_state_tiled_large_kernel",
|
| 126 |
-
"priority": 10,
|
| 127 |
-
"when": ["zeroStateContract", "kernelSize >= 32", "dim(shapes.inputT, 2) >= 256", "dim(shapes.inputT, 2) % 8 == 0", "tunables.tiledWorkgroupSize >= 1", "floor(tunables.tiledWorkgroupSize) == tunables.tiledWorkgroupSize", "tunables.tiledWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.tiledWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX", "(tunables.tiledWorkgroupSize * 8 + kernelSizePadded + (kernelSizePadded - 1) * causalDilation) * 4 <= device.limits.maxComputeWorkgroupStorageSize", "not channelsLast"],
|
| 128 |
-
"derive": {
|
| 129 |
-
"workgroupSize": "tunables.tiledWorkgroupSize",
|
| 130 |
-
"tileSize": "tunables.tiledWorkgroupSize * 8",
|
| 131 |
-
"inputTileSize": "tunables.tiledWorkgroupSize * 8 + (kernelSizePadded - 1) * causalDilation"
|
| 132 |
-
},
|
| 133 |
-
"passes": [
|
| 134 |
-
{
|
| 135 |
-
"id": "main",
|
| 136 |
-
"name": "CausalConvWithState.TiledLargeKernel",
|
| 137 |
-
"shader": "causal-conv-with-state-tiled.wgsl.jinja",
|
| 138 |
-
"bindings": ["input_main", "weight_main", "output_main", "present_state", "params"],
|
| 139 |
-
"dispatch": {
|
| 140 |
-
"x": "min(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 141 |
-
"y": "ceilDiv(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 142 |
-
"z": 1
|
| 143 |
-
}
|
| 144 |
-
}
|
| 145 |
-
]
|
| 146 |
-
},
|
| 147 |
-
{
|
| 148 |
-
"id": "zero_state",
|
| 149 |
-
"priority": 0,
|
| 150 |
-
"when": ["zeroStateContract"],
|
| 151 |
-
"derive": { "workgroupSize": "tunables.workgroupSize" },
|
| 152 |
-
"passes": [
|
| 153 |
-
{
|
| 154 |
-
"id": "main",
|
| 155 |
-
"name": "CausalConvWithState",
|
| 156 |
-
"shader": "causal-conv-with-state.wgsl.jinja",
|
| 157 |
-
"bindings": ["input_main", "weight_main", "output_main", "present_state", "params_main"],
|
| 158 |
-
"dispatch": {
|
| 159 |
-
"x": "min(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 160 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 161 |
-
"z": 1
|
| 162 |
-
}
|
| 163 |
-
}
|
| 164 |
-
]
|
| 165 |
-
},
|
| 166 |
-
{
|
| 167 |
-
"id": "state_bias_vec4",
|
| 168 |
-
"priority": 20,
|
| 169 |
-
"when": ["stateBiasContract", "kernelSize >= 2", "kernelSize <= 4", "dim(shapes.inputT, 2) >= 4", "dim(shapes.inputT, 2) % 4 == 0", "not channelsLast", "causalDilation == 1"],
|
| 170 |
-
"derive": {
|
| 171 |
-
"workgroupSize": 256,
|
| 172 |
-
"inputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 173 |
-
"outputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 174 |
-
"weightElem": "(\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\") if kernelSize == 4 else dtypes.T"
|
| 175 |
-
},
|
| 176 |
-
"passes": [
|
| 177 |
-
{
|
| 178 |
-
"id": "main",
|
| 179 |
-
"name": "CausalConvWithState.Vec4",
|
| 180 |
-
"shader": "causal-conv-with-state-vec4.wgsl.jinja",
|
| 181 |
-
"bindings": ["input", "weight", "bias", "past_state", "output", "present_state", "params"],
|
| 182 |
-
"dispatch": {
|
| 183 |
-
"x": "min(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 184 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 185 |
-
"z": 1
|
| 186 |
-
}
|
| 187 |
-
}
|
| 188 |
-
]
|
| 189 |
-
},
|
| 190 |
-
{
|
| 191 |
-
"id": "state_bias_tiled_large_kernel",
|
| 192 |
-
"priority": 10,
|
| 193 |
-
"when": ["stateBiasContract", "kernelSize >= 32", "dim(shapes.inputT, 2) >= 256", "dim(shapes.inputT, 2) % 8 == 0", "tunables.tiledWorkgroupSize >= 1", "floor(tunables.tiledWorkgroupSize) == tunables.tiledWorkgroupSize", "tunables.tiledWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.tiledWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX", "(tunables.tiledWorkgroupSize * 8 + kernelSizePadded + (kernelSizePadded - 1) * causalDilation) * 4 <= device.limits.maxComputeWorkgroupStorageSize", "not channelsLast"],
|
| 194 |
-
"derive": {
|
| 195 |
-
"workgroupSize": "tunables.tiledWorkgroupSize",
|
| 196 |
-
"tileSize": "tunables.tiledWorkgroupSize * 8",
|
| 197 |
-
"inputTileSize": "tunables.tiledWorkgroupSize * 8 + (kernelSizePadded - 1) * causalDilation"
|
| 198 |
-
},
|
| 199 |
-
"passes": [
|
| 200 |
-
{
|
| 201 |
-
"id": "main",
|
| 202 |
-
"name": "CausalConvWithState.TiledLargeKernel",
|
| 203 |
-
"shader": "causal-conv-with-state-tiled.wgsl.jinja",
|
| 204 |
-
"bindings": ["input_main", "weight_main", "bias", "past_state", "output_main", "present_state", "params"],
|
| 205 |
-
"dispatch": {
|
| 206 |
-
"x": "min(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 207 |
-
"y": "ceilDiv(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 208 |
-
"z": 1
|
| 209 |
-
}
|
| 210 |
-
}
|
| 211 |
-
]
|
| 212 |
-
},
|
| 213 |
-
{
|
| 214 |
-
"id": "state_bias",
|
| 215 |
-
"priority": 0,
|
| 216 |
-
"when": ["stateBiasContract"],
|
| 217 |
-
"derive": { "workgroupSize": "tunables.workgroupSize" },
|
| 218 |
-
"passes": [
|
| 219 |
-
{
|
| 220 |
-
"id": "main",
|
| 221 |
-
"name": "CausalConvWithState",
|
| 222 |
-
"shader": "causal-conv-with-state.wgsl.jinja",
|
| 223 |
-
"bindings": ["input_main", "weight_main", "bias", "past_state", "output_main", "present_state", "params_main"],
|
| 224 |
-
"dispatch": {
|
| 225 |
-
"x": "min(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 226 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 227 |
-
"z": 1
|
| 228 |
-
}
|
| 229 |
-
}
|
| 230 |
-
]
|
| 231 |
-
},
|
| 232 |
-
{
|
| 233 |
-
"id": "bias_no_state_vec4",
|
| 234 |
-
"priority": 20,
|
| 235 |
-
"when": ["biasNoStateContract", "kernelSize >= 2", "kernelSize <= 4", "dim(shapes.inputT, 2) >= 4", "dim(shapes.inputT, 2) % 4 == 0", "not channelsLast", "causalDilation == 1"],
|
| 236 |
-
"derive": {
|
| 237 |
-
"workgroupSize": 256,
|
| 238 |
-
"inputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 239 |
-
"outputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 240 |
-
"weightElem": "(\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\") if kernelSize == 4 else dtypes.T"
|
| 241 |
-
},
|
| 242 |
-
"passes": [
|
| 243 |
-
{
|
| 244 |
-
"id": "main",
|
| 245 |
-
"name": "CausalConvWithState.Vec4",
|
| 246 |
-
"shader": "causal-conv-with-state-vec4.wgsl.jinja",
|
| 247 |
-
"bindings": ["input", "weight", "bias", "output", "present_state", "params"],
|
| 248 |
-
"dispatch": {
|
| 249 |
-
"x": "min(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 250 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 251 |
-
"z": 1
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
]
|
| 255 |
-
},
|
| 256 |
-
{
|
| 257 |
-
"id": "bias_no_state_tiled_large_kernel",
|
| 258 |
-
"priority": 10,
|
| 259 |
-
"when": ["biasNoStateContract", "kernelSize >= 32", "dim(shapes.inputT, 2) >= 256", "dim(shapes.inputT, 2) % 8 == 0", "tunables.tiledWorkgroupSize >= 1", "floor(tunables.tiledWorkgroupSize) == tunables.tiledWorkgroupSize", "tunables.tiledWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.tiledWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX", "(tunables.tiledWorkgroupSize * 8 + kernelSizePadded + (kernelSizePadded - 1) * causalDilation) * 4 <= device.limits.maxComputeWorkgroupStorageSize", "not channelsLast"],
|
| 260 |
-
"derive": {
|
| 261 |
-
"workgroupSize": "tunables.tiledWorkgroupSize",
|
| 262 |
-
"tileSize": "tunables.tiledWorkgroupSize * 8",
|
| 263 |
-
"inputTileSize": "tunables.tiledWorkgroupSize * 8 + (kernelSizePadded - 1) * causalDilation"
|
| 264 |
-
},
|
| 265 |
-
"passes": [
|
| 266 |
-
{
|
| 267 |
-
"id": "main",
|
| 268 |
-
"name": "CausalConvWithState.TiledLargeKernel",
|
| 269 |
-
"shader": "causal-conv-with-state-tiled.wgsl.jinja",
|
| 270 |
-
"bindings": ["input_main", "weight_main", "bias", "output_main", "present_state", "params"],
|
| 271 |
-
"dispatch": {
|
| 272 |
-
"x": "min(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 273 |
-
"y": "ceilDiv(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 274 |
-
"z": 1
|
| 275 |
-
}
|
| 276 |
-
}
|
| 277 |
-
]
|
| 278 |
-
},
|
| 279 |
-
{
|
| 280 |
-
"id": "bias_no_state",
|
| 281 |
-
"priority": 0,
|
| 282 |
-
"when": ["biasNoStateContract"],
|
| 283 |
-
"derive": { "workgroupSize": "tunables.workgroupSize" },
|
| 284 |
-
"passes": [
|
| 285 |
-
{
|
| 286 |
-
"id": "main",
|
| 287 |
-
"name": "CausalConvWithState",
|
| 288 |
-
"shader": "causal-conv-with-state.wgsl.jinja",
|
| 289 |
-
"bindings": ["input_main", "weight_main", "bias", "output_main", "present_state", "params_main"],
|
| 290 |
-
"dispatch": {
|
| 291 |
-
"x": "min(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 292 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 293 |
-
"z": 1
|
| 294 |
-
}
|
| 295 |
-
}
|
| 296 |
-
]
|
| 297 |
-
},
|
| 298 |
-
{
|
| 299 |
-
"id": "state_no_bias_vec4",
|
| 300 |
-
"priority": 20,
|
| 301 |
-
"when": ["stateNoBiasContract", "kernelSize >= 2", "kernelSize <= 4", "dim(shapes.inputT, 2) >= 4", "dim(shapes.inputT, 2) % 4 == 0", "not channelsLast", "causalDilation == 1"],
|
| 302 |
-
"derive": {
|
| 303 |
-
"workgroupSize": 256,
|
| 304 |
-
"inputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 305 |
-
"outputVec4": "\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"",
|
| 306 |
-
"weightElem": "(\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\") if kernelSize == 4 else dtypes.T"
|
| 307 |
-
},
|
| 308 |
-
"passes": [
|
| 309 |
-
{
|
| 310 |
-
"id": "main",
|
| 311 |
-
"name": "CausalConvWithState.Vec4",
|
| 312 |
-
"shader": "causal-conv-with-state-vec4.wgsl.jinja",
|
| 313 |
-
"bindings": ["input", "weight", "past_state", "output", "present_state", "params"],
|
| 314 |
-
"dispatch": {
|
| 315 |
-
"x": "min(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 316 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)",
|
| 317 |
-
"z": 1
|
| 318 |
-
}
|
| 319 |
-
}
|
| 320 |
-
]
|
| 321 |
-
},
|
| 322 |
-
{
|
| 323 |
-
"id": "state_no_bias_tiled_large_kernel",
|
| 324 |
-
"priority": 10,
|
| 325 |
-
"when": ["stateNoBiasContract", "kernelSize >= 32", "dim(shapes.inputT, 2) >= 256", "dim(shapes.inputT, 2) % 8 == 0", "tunables.tiledWorkgroupSize >= 1", "floor(tunables.tiledWorkgroupSize) == tunables.tiledWorkgroupSize", "tunables.tiledWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.tiledWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX", "(tunables.tiledWorkgroupSize * 8 + kernelSizePadded + (kernelSizePadded - 1) * causalDilation) * 4 <= device.limits.maxComputeWorkgroupStorageSize", "not channelsLast"],
|
| 326 |
-
"derive": {
|
| 327 |
-
"workgroupSize": "tunables.tiledWorkgroupSize",
|
| 328 |
-
"tileSize": "tunables.tiledWorkgroupSize * 8",
|
| 329 |
-
"inputTileSize": "tunables.tiledWorkgroupSize * 8 + (kernelSizePadded - 1) * causalDilation"
|
| 330 |
-
},
|
| 331 |
-
"passes": [
|
| 332 |
-
{
|
| 333 |
-
"id": "main",
|
| 334 |
-
"name": "CausalConvWithState.TiledLargeKernel",
|
| 335 |
-
"shader": "causal-conv-with-state-tiled.wgsl.jinja",
|
| 336 |
-
"bindings": ["input_main", "weight_main", "past_state", "output_main", "present_state", "params"],
|
| 337 |
-
"dispatch": {
|
| 338 |
-
"x": "min(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 339 |
-
"y": "ceilDiv(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)",
|
| 340 |
-
"z": 1
|
| 341 |
-
}
|
| 342 |
-
}
|
| 343 |
-
]
|
| 344 |
-
},
|
| 345 |
-
{
|
| 346 |
-
"id": "state_no_bias",
|
| 347 |
-
"priority": 0,
|
| 348 |
-
"when": ["stateNoBiasContract"],
|
| 349 |
-
"derive": { "workgroupSize": "tunables.workgroupSize" },
|
| 350 |
-
"passes": [
|
| 351 |
-
{
|
| 352 |
-
"id": "main",
|
| 353 |
-
"name": "CausalConvWithState",
|
| 354 |
-
"shader": "causal-conv-with-state.wgsl.jinja",
|
| 355 |
-
"bindings": ["input_main", "weight_main", "past_state", "output_main", "present_state", "params_main"],
|
| 356 |
-
"dispatch": {
|
| 357 |
-
"x": "min(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 358 |
-
"y": "ceilDiv(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)",
|
| 359 |
-
"z": 1
|
| 360 |
-
}
|
| 361 |
-
}
|
| 362 |
-
]
|
| 363 |
-
}
|
| 364 |
-
]
|
| 365 |
-
}
|
|
|
|
| 1 |
+
{"domain":"com.microsoft","name":"CausalConvWithState","sinceVersion":1,"inputs":{"inputT":{"onnx":"input","dtype":"T","rank":3},"weightT":{"onnx":"weight","dtype":"T","rank":3},"biasT":{"onnx":"bias","dtype":"T","rank":1,"optional":true},"pastStateT":{"onnx":"past_state","dtype":"T","rank":"3 if attrs.state_window == 0 else 4","optional":true}},"outputs":{"outputT":{"onnx":"output","dtype":"T","rank":3,"shape":"shapes.inputT"},"presentStateT":{"onnx":"present_state","dtype":"T","rank":"3 if attrs.state_window == 0 else 4","shape":"([stateWindow] + stateShape) if windowed else stateShape"}},"attributes":{"activation":{"default":"none"},"channels_last":{"default":0},"dilation":{"default":1},"ndim":{"default":1},"state_window":{"default":0}},"attributeConstraints":{"activation":{"values":["none","silu","swish"]},"channels_last":{"values":[0,1]},"ndim":{"values":[1]}},"typeConstraints":{"T":["float32","float16"]},"tunables":{"workgroupSize":{"default":256},"tiledWorkgroupSize":{"default":128}},"derive":{"channels":"dim(shapes.inputT, 2 if attrs.channels_last == 1 else 1)","inputLength":"dim(shapes.inputT, 1 if attrs.channels_last == 1 else 2)","causalDilation":"attrs.dilation","channelsLast":"attrs.channels_last == 1","stateWindow":"attrs.state_window","windowed":"stateWindow > 0","stateWindowOk":"stateWindow >= 0 and stateWindow <= 8","kernelSize":"dim(shapes.weightT, ranks.weightT - 1)","kernelSizePadded":"ceilDiv(kernelSize, 4) * 4","weightRankOk":"ranks.weightT == 3 and dim(shapes.weightT, 1) == 1","stateLength":"(kernelSize - 1) * causalDilation","stateSlotStride":"dim(shapes.inputT, 0) * channels * stateLength","windowedLengthOk":"not windowed or inputLength > 0","stateShape":"[dim(shapes.inputT, 0), stateLength, channels] if channelsLast else [dim(shapes.inputT, 0), channels, stateLength]","presentStateOk":"sameShape(shapes.presentStateT, ([stateWindow] + stateShape) if windowed else stateShape)","pastStateOk":"not present.pastStateT or (tensorDtypes.pastStateT == tensorDtypes.inputT and sameShape(shapes.pastStateT, ([stateWindow] + stateShape) if windowed else stateShape))","biasOk":"not present.biasT or (ranks.biasT == 1 and tensorDtypes.biasT == tensorDtypes.inputT and dim(shapes.biasT, 0) == channels)","contract":"ranks.inputT == 3 and weightRankOk and ranks.outputT == 3 and (tensorDtypes.inputT == \"float32\" or tensorDtypes.inputT == \"float16\") and tensorDtypes.weightT == tensorDtypes.inputT and tensorDtypes.outputT == tensorDtypes.inputT and tensorDtypes.presentStateT == tensorDtypes.inputT and f16Ok(dtypes.T) and channels == dim(shapes.weightT, 0) and sameShape(shapes.outputT, shapes.inputT) and stateWindowOk and windowedLengthOk and presentStateOk and pastStateOk and biasOk and kernelSize >= 1 and causalDilation >= 1 and floor(causalDilation) == causalDilation","useSilu":"attrs.activation == \"silu\" or attrs.activation == \"swish\"","inputScalar":"dtypes.T","outputScalar":"dtypes.T","hasStateWindow":"windowed","hasBias":"present.biasT","hasState":"present.pastStateT"},"bindings":{"input":{"arg":"inputT","elementType":"$inputVec4"},"weight":{"arg":"weightT","elementType":"$weightElem"},"output":{"arg":"outputT","elementType":"$outputVec4"},"present_state":{"arg":"presentStateT","elementType":"$outputScalar"},"params":{"struct":[{"name":"batchSize","type":"u32","value":"dim(shapes.inputT, 0)"},{"name":"channels","type":"u32","value":"channels"},{"name":"length","type":"u32","value":"inputLength"},{"name":"stateWindow","type":"u32","value":"stateWindow"},{"name":"stateSlotStride","type":"u32","value":"stateSlotStride"}]},"bias":{"arg":"biasT","elementType":"$inputScalar","when":"hasBias"},"past_state":{"arg":"pastStateT","elementType":"$inputScalar","when":"hasState"},"input_main":{"arg":"inputT","name":"input","elementType":"$inputScalar"},"weight_main":{"arg":"weightT","name":"weight","elementType":"$inputScalar"},"output_main":{"arg":"outputT","name":"output","elementType":"$outputScalar"},"params_main":{"name":"params","struct":[{"name":"batchSize","type":"u32","value":"dim(shapes.inputT, 0)"},{"name":"channels","type":"u32","value":"channels"},{"name":"length","type":"u32","value":"inputLength"},{"name":"kernelSize","type":"u32","value":"kernelSize"},{"name":"stateWindow","type":"u32","value":"stateWindow"},{"name":"stateSlotStride","type":"u32","value":"stateSlotStride"}]}},"variants":[{"id":"vec4","priority":20,"when":["contract","kernelSize >= 2","kernelSize <= 4","dim(shapes.inputT, 2) >= 4","dim(shapes.inputT, 2) % 4 == 0","not channelsLast","causalDilation == 1"],"derive":{"workgroupSize":256,"inputVec4":"\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"","outputVec4":"\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\"","weightElem":"(\"vec4<f16>\" if tensorDtypes.inputT == \"float16\" else \"vec4<f32>\") if kernelSize == 4 else dtypes.T"},"passes":[{"id":"main","name":"CausalConvWithState.Vec4","shader":"causal-conv-with-state-vec4.wgsl.jinja","bindings":["input","weight","bias","past_state","output","present_state","params"],"dispatch":{"x":"min(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)","y":"ceilDiv(ceilDiv((dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * (dim(shapes.outputT, 2) / 4)), (workgroupSize)), 65535)","z":1}}]},{"id":"tiled_large_kernel","priority":10,"when":["contract","kernelSize >= 32","dim(shapes.inputT, 2) >= 256","dim(shapes.inputT, 2) % 8 == 0","tunables.tiledWorkgroupSize >= 1","floor(tunables.tiledWorkgroupSize) == tunables.tiledWorkgroupSize","tunables.tiledWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup","tunables.tiledWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX","(tunables.tiledWorkgroupSize * 8 + kernelSizePadded + (kernelSizePadded - 1) * causalDilation) * 4 <= device.limits.maxComputeWorkgroupStorageSize","not channelsLast"],"derive":{"workgroupSize":"min(tunables.tiledWorkgroupSize, pow2ceil(ceilDiv(dim(shapes.inputT, 2), 8)))","tileSize":"workgroupSize * 8","packedWindow":"causalDilation == 1 and (tileSize + 2 * kernelSizePadded) * 4 <= device.limits.maxComputeWorkgroupStorageSize","inputTileSize":"tileSize + (kernelSizePadded - 1) * causalDilation"},"passes":[{"id":"main","name":"CausalConvWithState.TiledLargeKernel","shader":"causal-conv-with-state-tiled.wgsl.jinja","bindings":["input_main","weight_main","bias","past_state","output_main","present_state","params"],"dispatch":{"x":"min(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)","y":"ceilDiv(dim(shapes.outputT, 0) * dim(shapes.outputT, 1) * ceilDiv(dim(shapes.outputT, 2), tileSize), 65535)","z":1}}]},{"id":"scalar","priority":0,"when":["contract"],"derive":{"workgroupSize":"tunables.workgroupSize"},"passes":[{"id":"main","name":"CausalConvWithState","shader":"causal-conv-with-state.wgsl.jinja","bindings":["input_main","weight_main","bias","past_state","output_main","present_state","params_main"],"dispatch":{"x":"min(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)","y":"ceilDiv(ceilDiv((dim(shapes.inputT, 0) * channels * max(1, inputLength)), (workgroupSize)), 65535)","z":1}}]}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/webgpu/metadata.json
CHANGED
|
@@ -1,36 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "com.microsoft.CausalConvWithState",
|
| 3 |
-
"id": "_com_microsoft_causalconvwithstate_webgpu_497b636",
|
| 4 |
-
"version": 1,
|
| 5 |
-
"license": "Apache-2.0",
|
| 6 |
-
"backend": { "type": "webgpu" },
|
| 7 |
-
"digest": {
|
| 8 |
-
"algorithm": "sha256",
|
| 9 |
-
"files": {
|
| 10 |
-
"bench.json": "VZ4iX04MaTq+cGsDaUFxIgUMPbEm9X5xXeAp+B/c+gw=",
|
| 11 |
-
"causal-conv-with-state-tiled.wgsl.jinja": "Q5bbjBXpHMRSmHovwIXIQnDaeHJniM+tS48x3lTDPAw=",
|
| 12 |
-
"causal-conv-with-state-vec4.wgsl.jinja": "vM/mv4hndKQ05w6NVLjq1rBHA2qPEXMdI3/nwwagvYk=",
|
| 13 |
-
"causal-conv-with-state.wgsl.jinja": "Pr6GwBHPU2HnWONPjCbz46QB24JK+34Qj3gu8P6GJBY=",
|
| 14 |
-
"manifest.json": "/R4bylER5z0eL1IPPdzJTMTvdcec+NNC/xh4gBR3cIc=",
|
| 15 |
-
"test.json": "rEWMf93peBX7/6HRgGQLjEPNevPSqCOmaATkY22GaEI="
|
| 16 |
-
}
|
| 17 |
-
},
|
| 18 |
-
"provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } },
|
| 19 |
-
"webgpu": {
|
| 20 |
-
"manifestSpec": "2.1",
|
| 21 |
-
"variants": {
|
| 22 |
-
"zero_state_vec4": ["causal-conv-with-state-vec4.wgsl.jinja"],
|
| 23 |
-
"zero_state_tiled_large_kernel": ["causal-conv-with-state-tiled.wgsl.jinja"],
|
| 24 |
-
"zero_state": ["causal-conv-with-state.wgsl.jinja"],
|
| 25 |
-
"state_bias_vec4": ["causal-conv-with-state-vec4.wgsl.jinja"],
|
| 26 |
-
"state_bias_tiled_large_kernel": ["causal-conv-with-state-tiled.wgsl.jinja"],
|
| 27 |
-
"state_bias": ["causal-conv-with-state.wgsl.jinja"],
|
| 28 |
-
"bias_no_state_vec4": ["causal-conv-with-state-vec4.wgsl.jinja"],
|
| 29 |
-
"bias_no_state_tiled_large_kernel": ["causal-conv-with-state-tiled.wgsl.jinja"],
|
| 30 |
-
"bias_no_state": ["causal-conv-with-state.wgsl.jinja"],
|
| 31 |
-
"state_no_bias_vec4": ["causal-conv-with-state-vec4.wgsl.jinja"],
|
| 32 |
-
"state_no_bias_tiled_large_kernel": ["causal-conv-with-state-tiled.wgsl.jinja"],
|
| 33 |
-
"state_no_bias": ["causal-conv-with-state.wgsl.jinja"]
|
| 34 |
-
}
|
| 35 |
-
}
|
| 36 |
-
}
|
|
|
|
| 1 |
+
{"name":"com.microsoft.CausalConvWithState","id":"_com_microsoft_causalconvwithstate_webgpu_c94e799","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"Z/7kPiuJbwnjsqpA9naeKxpyb4VWMUpfNLS9LPMVJBI=","causal-conv-with-state-tiled.wgsl.jinja":"+Mn+2IXBisLs6cd/7dSBakyuOhrfskpj1BMqQcvCwrQ=","causal-conv-with-state-vec4.wgsl.jinja":"lyaCC47bQy6A2eZLI+Szdpfuk4SG2qAOPK/SGqwLZRI=","causal-conv-with-state.wgsl.jinja":"jGfhg04r6SRm2QXLobfTNnbBbaVzvoCi3PRUyJw2b88=","manifest.json":"F3h/w85sAOZ1VNAXup7QFRLr779xWxjkvc+KI1xAXDs=","test.json":"0LelSn2X6Ku2rnyQWDHrILP25d1uN0JBvj7AQHhEY3g="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/webgpu/test.json
CHANGED
|
@@ -479,7 +479,7 @@
|
|
| 479 |
"presentStateT": { "dtype": "float32", "shape": [2, 2, 3], "tolerance": 0.000001 }
|
| 480 |
},
|
| 481 |
"provenance": {
|
| 482 |
-
"notes": "Kernel 4 over a length
|
| 483 |
}
|
| 484 |
},
|
| 485 |
{
|
|
@@ -507,7 +507,7 @@
|
|
| 507 |
"presentStateT": { "dtype": "float32", "shape": [2, 2, 3], "tolerance": 0.000001 }
|
| 508 |
},
|
| 509 |
"provenance": {
|
| 510 |
-
"notes": "Kernel 4 over a length
|
| 511 |
}
|
| 512 |
},
|
| 513 |
{
|
|
@@ -945,7 +945,7 @@
|
|
| 945 |
{
|
| 946 |
"name": "large_kernel_tiled_bias_no_state_window2",
|
| 947 |
"provenance": {
|
| 948 |
-
"notes": "
|
| 949 |
},
|
| 950 |
"attrs": { "activation": "silu", "state_window": 2 },
|
| 951 |
"inputs": {
|
|
@@ -969,7 +969,7 @@
|
|
| 969 |
{
|
| 970 |
"name": "large_kernel_tiled_state_no_bias_window2",
|
| 971 |
"provenance": {
|
| 972 |
-
"notes": "
|
| 973 |
},
|
| 974 |
"attrs": { "activation": "none", "state_window": 2 },
|
| 975 |
"inputs": {
|
|
@@ -1105,7 +1105,7 @@
|
|
| 1105 |
},
|
| 1106 |
{
|
| 1107 |
"name": "f16_k4_vec4_zero_state_silu",
|
| 1108 |
-
"provenance": { "notes": "
|
| 1109 |
"attrs": { "activation": "silu" },
|
| 1110 |
"inputs": {
|
| 1111 |
"inputT": {
|
|
@@ -1126,9 +1126,7 @@
|
|
| 1126 |
},
|
| 1127 |
{
|
| 1128 |
"name": "f16_large_kernel_tiled_state_bias",
|
| 1129 |
-
"provenance": {
|
| 1130 |
-
"notes": "float16 on the tiled large-kernel path, which stages the weight and the virtual input in float32 workgroup memory regardless of the tensor type."
|
| 1131 |
-
},
|
| 1132 |
"inputs": {
|
| 1133 |
"inputT": {
|
| 1134 |
"dtype": "float16",
|
|
@@ -1154,9 +1152,7 @@
|
|
| 1154 |
},
|
| 1155 |
{
|
| 1156 |
"name": "weight_rank3_k4_vec4_zero_state",
|
| 1157 |
-
"provenance": {
|
| 1158 |
-
"notes": "A rank-3 weight on the four-tap vectorized kernel, where the kernel extent is read as a vec4 rather than element by element."
|
| 1159 |
-
},
|
| 1160 |
"inputs": {
|
| 1161 |
"inputT": {
|
| 1162 |
"dtype": "float32",
|
|
@@ -1307,7 +1303,7 @@
|
|
| 1307 |
{
|
| 1308 |
"name": "vec4_state_window_bias_past_state",
|
| 1309 |
"provenance": {
|
| 1310 |
-
"notes": "The windowed vec4 arm with both a bias and a past_state: the
|
| 1311 |
},
|
| 1312 |
"attrs": { "activation": "silu", "state_window": 3 },
|
| 1313 |
"inputs": {
|
|
@@ -2840,6 +2836,44 @@
|
|
| 2840 |
"source": "onnxruntime/test/contrib_ops/causal_conv_with_state_op_test.cc",
|
| 2841 |
"test": "ChannelsLastDilated"
|
| 2842 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2843 |
}
|
| 2844 |
]
|
| 2845 |
}
|
|
|
|
| 479 |
"presentStateT": { "dtype": "float32", "shape": [2, 2, 3], "tolerance": 0.000001 }
|
| 480 |
},
|
| 481 |
"provenance": {
|
| 482 |
+
"notes": "Kernel 4 over a sequence of length 4 (a multiple of four) with 2 channels and batch 2, with a bias, no carried state and SiLU: the first positions' taps read a zero prefix rather than past_state."
|
| 483 |
}
|
| 484 |
},
|
| 485 |
{
|
|
|
|
| 507 |
"presentStateT": { "dtype": "float32", "shape": [2, 2, 3], "tolerance": 0.000001 }
|
| 508 |
},
|
| 509 |
"provenance": {
|
| 510 |
+
"notes": "Kernel 4 over a sequence of length 4 (a multiple of four) with 2 channels and batch 2, carried state, no bias and SiLU: the first positions' taps read past_state and no bias is added."
|
| 511 |
}
|
| 512 |
},
|
| 513 |
{
|
|
|
|
| 945 |
{
|
| 946 |
"name": "large_kernel_tiled_bias_no_state_window2",
|
| 947 |
"provenance": {
|
| 948 |
+
"notes": "Kernel 32 over a length of 256 with a bias, no past state, SiLU and state_window 2: the windowed present state (31 values per window) is computed from the input alone."
|
| 949 |
},
|
| 950 |
"attrs": { "activation": "silu", "state_window": 2 },
|
| 951 |
"inputs": {
|
|
|
|
| 969 |
{
|
| 970 |
"name": "large_kernel_tiled_state_no_bias_window2",
|
| 971 |
"provenance": {
|
| 972 |
+
"notes": "Kernel 32 over a length of 256 with a past state, no bias, no activation and state_window 2: the windowed past state is read and the windowed present state written."
|
| 973 |
},
|
| 974 |
"attrs": { "activation": "none", "state_window": 2 },
|
| 975 |
"inputs": {
|
|
|
|
| 1105 |
},
|
| 1106 |
{
|
| 1107 |
"name": "f16_k4_vec4_zero_state_silu",
|
| 1108 |
+
"provenance": { "notes": "float16 kernel 4 over input [2,3,8] (3 channels, length 8) with zero state and SiLU." },
|
| 1109 |
"attrs": { "activation": "silu" },
|
| 1110 |
"inputs": {
|
| 1111 |
"inputT": {
|
|
|
|
| 1126 |
},
|
| 1127 |
{
|
| 1128 |
"name": "f16_large_kernel_tiled_state_bias",
|
| 1129 |
+
"provenance": { "notes": "float16 kernel 32 over a length of 256 with a past state and a bias." },
|
|
|
|
|
|
|
| 1130 |
"inputs": {
|
| 1131 |
"inputT": {
|
| 1132 |
"dtype": "float16",
|
|
|
|
| 1152 |
},
|
| 1153 |
{
|
| 1154 |
"name": "weight_rank3_k4_vec4_zero_state",
|
| 1155 |
+
"provenance": { "notes": "A rank-3 weight [3,1,4] (kernel 4) over input [2,3,8] with zero state." },
|
|
|
|
|
|
|
| 1156 |
"inputs": {
|
| 1157 |
"inputT": {
|
| 1158 |
"dtype": "float32",
|
|
|
|
| 1303 |
{
|
| 1304 |
"name": "vec4_state_window_bias_past_state",
|
| 1305 |
"provenance": {
|
| 1306 |
+
"notes": "The windowed vec4 arm with both a bias and a past_state: the past-state slot and the window slot stride are read in the same kernel."
|
| 1307 |
},
|
| 1308 |
"attrs": { "activation": "silu", "state_window": 3 },
|
| 1309 |
"inputs": {
|
|
|
|
| 2836 |
"source": "onnxruntime/test/contrib_ops/causal_conv_with_state_op_test.cc",
|
| 2837 |
"test": "ChannelsLastDilated"
|
| 2838 |
}
|
| 2839 |
+
},
|
| 2840 |
+
{
|
| 2841 |
+
"name": "ragged_filter_ignores_future_infinity",
|
| 2842 |
+
"provenance": {
|
| 2843 |
+
"notes": "A future infinity is outside the first four causal windows. It enters the fifth window and recurs within every later window."
|
| 2844 |
+
},
|
| 2845 |
+
"attrs": { "activation": "none" },
|
| 2846 |
+
"inputs": {
|
| 2847 |
+
"inputT": {
|
| 2848 |
+
"shape": [1, 1, 256],
|
| 2849 |
+
"dtype": "float32",
|
| 2850 |
+
"data": { "kind": "cycle", "values": [1.0, 1.0, 1.0, 1.0, "Infinity"] }
|
| 2851 |
+
},
|
| 2852 |
+
"weightT": { "shape": [1, 1, 33], "dtype": "float32", "data": { "kind": "constant", "value": 1.0 } }
|
| 2853 |
+
},
|
| 2854 |
+
"outputs": {
|
| 2855 |
+
"outputT": { "dtype": "float32", "shape": [1, 1, 256], "tolerance": 0 },
|
| 2856 |
+
"presentStateT": { "dtype": "float32", "shape": [1, 1, 32], "tolerance": 0 }
|
| 2857 |
+
}
|
| 2858 |
+
},
|
| 2859 |
+
{
|
| 2860 |
+
"name": "dilated_ragged_filter_ignores_future_infinity",
|
| 2861 |
+
"provenance": {
|
| 2862 |
+
"notes": "Dilation samples every second position. Padded weights must never read a future infinity into an earlier finite output."
|
| 2863 |
+
},
|
| 2864 |
+
"attrs": { "activation": "none", "dilation": 2 },
|
| 2865 |
+
"inputs": {
|
| 2866 |
+
"inputT": {
|
| 2867 |
+
"shape": [1, 1, 256],
|
| 2868 |
+
"dtype": "float32",
|
| 2869 |
+
"data": { "kind": "cycle", "values": [1.0, 1.0, 1.0, 1.0, "Infinity"] }
|
| 2870 |
+
},
|
| 2871 |
+
"weightT": { "shape": [1, 1, 33], "dtype": "float32", "data": { "kind": "constant", "value": 1.0 } }
|
| 2872 |
+
},
|
| 2873 |
+
"outputs": {
|
| 2874 |
+
"outputT": { "dtype": "float32", "shape": [1, 1, 256], "tolerance": 0 },
|
| 2875 |
+
"presentStateT": { "dtype": "float32", "shape": [1, 1, 64], "tolerance": 0 }
|
| 2876 |
+
}
|
| 2877 |
}
|
| 2878 |
]
|
| 2879 |
}
|