sync 4385228f788d
Browse filesFiles changed (8)
53 unmodified lines54555657585960616263646566676869707172737475767778798081828384858687885758596061929394959697986263646566676869707172103737475767778798081821111128384858687888990919293949596979853 unmodified lines
One implementation is selected per call from the device capabilities, the request shapes and the dtypes; these notes say what each one covers.
- `hidden1_f32_no_beta` — Closed-form one-element rows bind only gamma, optional beta, the output, and row parameters. Each invocation writes one row without reading the unused residual inputs.- `hidden1_f32_beta` — Closed-form one-element rows bind only gamma, optional beta, the output, and row parameters. Each invocation writes one row without reading the unused residual inputs.- `hidden1_f16_no_beta` — Closed-form one-element rows bind only gamma, optional beta, the output, and row parameters. Each invocation writes one row without reading the unused residual inputs.- `hidden1_f16_beta` — Closed-form one-element rows bind only gamma, optional beta, the output, and row parameters. Each invocation writes one row without reading the unused residual inputs.- `stats_mean_plain` — Row normalization returning mean statistics with `plain` optional inputs and outputs.- `stats_mean_residual` — Row normalization returning mean statistics with `residual` optional inputs and outputs.- `stats_mean_beta` — Row normalization returning mean statistics with `beta` optional inputs and outputs.- `stats_mean_beta_residual` — Row normalization returning mean statistics with `beta_residual` optional inputs and outputs.- `stats_mean_bias` — Row normalization returning mean statistics with `bias` optional inputs and outputs.- `stats_mean_bias_residual` — Row normalization returning mean statistics with `bias_residual` optional inputs and outputs.- `stats_mean_bias_beta` — Row normalization returning mean statistics with `bias_beta` optional inputs and outputs.- `stats_mean_bias_beta_residual` — Row normalization returning mean statistics with `bias_beta_residual` optional inputs and outputs.- `stats_inv_plain` — Row normalization returning inv statistics with `plain` optional inputs and outputs.- `stats_inv_residual` — Row normalization returning inv statistics with `residual` optional inputs and outputs.- `stats_inv_beta` — Row normalization returning inv statistics with `beta` optional inputs and outputs.- `stats_inv_beta_residual` — Row normalization returning inv statistics with `beta_residual` optional inputs and outputs.- `stats_inv_bias` — Row normalization returning inv statistics with `bias` optional inputs and outputs.- `stats_inv_bias_residual` — Row normalization returning inv statistics with `bias_residual` optional inputs and outputs.- `stats_inv_bias_beta` — Row normalization returning inv statistics with `bias_beta` optional inputs and outputs.- `stats_inv_bias_beta_residual` — Row normalization returning inv statistics with `bias_beta_residual` optional inputs and outputs.- `stats_both_plain` — Row normalization returning both statistics with `plain` optional inputs and outputs.- `stats_both_residual` — Row normalization returning both statistics with `residual` optional inputs and outputs.- `stats_both_beta` — Row normalization returning both statistics with `beta` optional inputs and outputs.- `stats_both_beta_residual` — Row normalization returning both statistics with `beta_residual` optional inputs and outputs.- `stats_both_bias` — Row normalization returning both statistics with `bias` optional inputs and outputs.- `stats_both_bias_residual` — Row normalization returning both statistics with `bias_residual` optional inputs and outputs.- `stats_both_bias_beta` — Row normalization returning both statistics with `bias_beta` optional inputs and outputs.- `stats_both_bias_beta_residual` — Row normalization returning both statistics with `bias_beta_residual` optional inputs and outputs.
## Device requirements
Some implementation variants require `shader-f16`. These are route-specific capabilities, not package-wide requirements; availability also depends on the request shape and dtype.- `row` — One workgroup reduces each row; one-element rows instead run one invocation each and classify the rounded input-plus-skip residual and scale before using their closed-form epilogue.- `stats` — Row normalization that also returns the requested statistics; when both are requested the row pass packs them and a second pass copies them out.
## Files
- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, per-variant templates, provenance)- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](build/webgpu/test.json) — correctness cases- [`bench.json`](build/webgpu/bench.json) — benchmark cases- [`norm-skip-row-vec4.wgsl.jinja`](build/webgpu/norm-skip-row-vec4.wgsl.jinja)- [`norm-skip-row.wgsl.jinja`](build/webgpu/norm-skip-row.wgsl.jinja)- [`norm-stats-copy.wgsl.jinja`](build/webgpu/norm-stats-copy.wgsl.jinja)- [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.SkipLayerNormalization/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)- [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.SkipLayerNormalization/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.SkipLayerNormalization/blob/v1/build/webgpu/test.json) — correctness cases- [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.SkipLayerNormalization/blob/v1/build/webgpu/bench.json) — benchmark cases- [`norm-skip-row-vec4.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.SkipLayerNormalization/blob/v1/build/webgpu/norm-skip-row-vec4.wgsl.jinja)- [`norm-skip-row.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.SkipLayerNormalization/blob/v1/build/webgpu/norm-skip-row.wgsl.jinja)- [`norm-stats-copy.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.SkipLayerNormalization/blob/v1/build/webgpu/norm-stats-copy.wgsl.jinja)
## Use with `@huggingface/kernels`
```shnpm install --save-exact @huggingface/kernels@0.0.1-preview.3npm install --save-exact @huggingface/kernels@0.0.1-preview.4```
Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
```jsimport { getKernel } from "@huggingface/kernels";
const kernel = await getKernel("webgpu-kernels/com.microsoft.SkipLayerNormalization", { version: 1 });
const inputTData = Float32Array.of(0.8, -0.5, 0, 1, 0.5, 0.2, 0.3, -0.6);const skipTData = Float32Array.of(0.1, -0.2, 0.3, 1, 0.5, 0.1, 0.4, 1.6);const gammaTData = Float32Array.of(0.3, 0.2, 4, 2.2);
const { outputT } = await kernel({ inputT: { data: inputTData, shape: [2, 4] }, skipT: { data: skipTData, shape: [2, 4] }, gammaT: { data: gammaTData, shape: [4] },});console.log({ outputT });```136 unmodified lines137138139140141142143144145146147148149150151152153154155156140141142136 unmodified lines }, "bench": { "metrics": [{ "type": "bandwidth", "value": "4 * (4 * args.rows * args.hidden + 2 * args.hidden)" }] } }, { "name": "skip-layernorm-f32-4096x768-hidden768-aligned", "preset": "model", "vars": { "rows": 4096, "hidden": 768 }, "attrs": { "epsilon": 0.00001 }, "inputs": { "inputT": { "shape": [4096, 768], "dtype": "float32", "dist": "normal", "seed": 413, "scale": 0.2 }, "skipT": { "shape": [4096, 768], "dtype": "float32", "dist": "normal", "seed": 414, "scale": 0.2 }, "gammaT": { "shape": [768], "dtype": "float32", "dist": "uniform", "seed": 415, "scale": 0.1, "offset": 1 }, "betaT": { "shape": [768], "dtype": "float32", "dist": "normal", "seed": 416, "scale": 0.1 } }, "outputs": { "outputT": { "shape": [4096, 768], "dtype": "float32" }, "residualT": { "shape": [4096, 768], "dtype": "float32" } }, "bench": { "metrics": [{ "type": "bandwidth", "value": "4 * (4 * args.rows * args.hidden + 2 * args.hidden)" }] } }, { "name": "skip-layernorm-f32-rows1-hidden4096-decode", "preset": "model",123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531{ "domain": "com.microsoft", "name": "SkipLayerNormalization", "sinceVersion": 1, "inputs": { "inputT": { "onnx": "input", "dtype": "T" }, "skipT": { "onnx": "skip", "dtype": "T" }, "gammaT": { "onnx": "gamma", "dtype": "T", "rank": 1 }, "betaT": { "onnx": "beta", "dtype": "T", "rank": 1, "optional": true }, "biasT": { "onnx": "bias", "dtype": "T", "rank": 1, "optional": true } }, "outputs": { "outputT": { "onnx": "output", "dtype": "T", "rank": "ranks.inputT", "shape": "shapes.inputT" }, "meanT": { "onnx": "mean", "dtype": "U", "optional": true, "rank": "ranks.inputT", "shape": "prefix(shapes.inputT, ranks.inputT - 1) + [1]" }, "invStdT": { "onnx": "inv_std_var", "dtype": "U", "optional": true, "rank": "ranks.inputT", "shape": "prefix(shapes.inputT, ranks.inputT - 1) + [1]" }, "residualT": { "onnx": "input_skip_bias_sum", "dtype": "T", "rank": "ranks.inputT", "optional": true, "shape": "shapes.inputT" } }, "attributes": { "epsilon": { "default": 9.999999960041972e-13 } }, "typeConstraints": { "T": ["float32", "float16"], "U": ["float32"] }, "tunables": { "MAX_WORKGROUP_SIZE": { "default": 256 } }, "derive": { "rowCount": "numel(shapes.inputT) / max(1, dim(shapes.inputT, -1))", "hiddenSize": "dim(shapes.inputT, -1)", "skipWg": "max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX)) if hiddenSize == 1 else (max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX, pow2ceil(hiddenSize))))", "skipWgVec4": "max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX, pow2ceil(ceilDiv(hiddenSize, 4))))", "rowDispatchFits": "rowCount <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "normResourcesFit": "skipWg * 8 <= device.limits.maxComputeWorkgroupStorageSize and skipWgVec4 * 8 <= device.limits.maxComputeWorkgroupStorageSize", "epsilonOk": "attrs.epsilon >= 0", "coreContract": "epsilonOk and (ranks.inputT == 2 or ranks.inputT == 3) and ranks.skipT == ranks.inputT and ranks.gammaT == 1 and ranks.outputT == ranks.inputT and sameShape(shapes.inputT, shapes.skipT) and sameShape(shapes.outputT, shapes.inputT) and dim(shapes.inputT, -1) > 0 and dim(shapes.gammaT, 0) == dim(shapes.inputT, -1)", "residualOutputContract": "present.residualT and sameShape(shapes.residualT, shapes.inputT)", "outputOnlyContract": "not present.residualT", "f32MainDtypes": "tensorDtypes.inputT == \"float32\" and tensorDtypes.skipT == \"float32\" and tensorDtypes.gammaT == \"float32\" and tensorDtypes.outputT == \"float32\"", "f16MainDtypes": "tensorDtypes.inputT == \"float16\" and tensorDtypes.skipT == \"float16\" and tensorDtypes.gammaT == \"float16\" and tensorDtypes.outputT == \"float16\"", "f32ResidualDtypes": "f32MainDtypes and tensorDtypes.residualT == \"float32\" if present.residualT else false", "f16ResidualDtypes": "f16MainDtypes and tensorDtypes.residualT == \"float16\" if present.residualT else false", "vec4Aligned": "dim(shapes.inputT, -1) % 4 == 0", "hasSubgroups": "device.features.has(\"subgroups\") and device.wgslLanguageFeatures.has(\"subgroup_id\")", "hasF16": "device.features.has(\"shader-f16\")", "statsRequested": "present.meanT or present.invStdT", "portableWideExecution": "not has(device.adapterInfo, \"subgroupMinSize\") or device.adapterInfo.subgroupMinSize >= 32", "broadcastRows": "dim(shapes.inputT, 0) * dim(shapes.inputT, 1)", "broadcastHiddenSize": "dim(shapes.inputT, 2)", "broadcastSkipWgVec4": "max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX, pow2ceil(ceilDiv(broadcastHiddenSize, 4))))", "broadcastDispatchFits": "broadcastRows <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "broadcastResourcesFit": "broadcastSkipWgVec4 * 8 <= device.limits.maxComputeWorkgroupStorageSize", "betaContract": "false if not present.betaT else (ranks.betaT == 1 and dim(shapes.betaT, 0) == dim(shapes.inputT, -1))", "noBetaContract": "not present.betaT", "broadcastSkipShapeOk": "(ranks.skipT == 2 and dim(shapes.skipT, 0) == dim(shapes.inputT, 1) and dim(shapes.skipT, 1) == dim(shapes.inputT, 2)) or (ranks.skipT == 3 and ((dim(shapes.skipT, 0) == 1 and dim(shapes.skipT, 1) == dim(shapes.inputT, 1) and dim(shapes.skipT, 2) == dim(shapes.inputT, 2)) or sameShape(shapes.skipT, shapes.inputT)))", "broadcastOutputOnlyContract": "false if ranks.inputT != 3 or not present.betaT else (epsilonOk and not present.biasT and not present.residualT and dim(shapes.inputT, 2) % 4 == 0 and broadcastSkipShapeOk and ranks.gammaT == 1 and ranks.betaT == 1 and ranks.outputT == 3 and tensorDtypes.inputT == \"float32\" and tensorDtypes.skipT == \"float32\" and tensorDtypes.gammaT == \"float32\" and tensorDtypes.betaT == \"float32\" and tensorDtypes.outputT == \"float32\" and dim(shapes.inputT, 2) > 0 and dim(shapes.gammaT, 0) == dim(shapes.inputT, 2) and dim(shapes.betaT, 0) == dim(shapes.inputT, 2) and sameShape(shapes.outputT, shapes.inputT))", "f32_beta_no_bias_residual_contract": "coreContract and residualOutputContract and betaContract and f32ResidualDtypes and not present.biasT and tensorDtypes.betaT == \"float32\"", "f32_beta_bias_residual_contract": "false if not present.biasT else (coreContract and residualOutputContract and betaContract and f32ResidualDtypes and ranks.biasT == 1 and tensorDtypes.betaT == \"float32\" and tensorDtypes.biasT == \"float32\" and dim(shapes.biasT, 0) == hiddenSize)", "f16_beta_bias_residual_contract": "false if not present.biasT else (hasF16 and coreContract and residualOutputContract and betaContract and f16ResidualDtypes and ranks.biasT == 1 and tensorDtypes.betaT == \"float16\" and tensorDtypes.biasT == \"float16\" and dim(shapes.biasT, 0) == hiddenSize)", "f32_no_beta_output_contract": "coreContract and outputOnlyContract and noBetaContract and f32MainDtypes and not present.biasT", "f32_beta_no_bias_output_only_contract": "coreContract and outputOnlyContract and betaContract and f32MainDtypes and not present.biasT and tensorDtypes.betaT == \"float32\"", "f32_beta_bias_output_only_contract": "false if not present.biasT else (coreContract and outputOnlyContract and betaContract and f32MainDtypes and ranks.biasT == 1 and tensorDtypes.betaT == \"float32\" and tensorDtypes.biasT == \"float32\" and dim(shapes.biasT, 0) == hiddenSize)", "f16_no_beta_output_contract": "hasF16 and coreContract and outputOnlyContract and noBetaContract and f16MainDtypes and not present.biasT", "f16_beta_no_bias_output_only_contract": "hasF16 and coreContract and outputOnlyContract and betaContract and f16MainDtypes and not present.biasT and tensorDtypes.betaT == \"float16\"", "f16_beta_bias_output_only_contract": "false if not present.biasT else (hasF16 and coreContract and outputOnlyContract and betaContract and f16MainDtypes and ranks.biasT == 1 and tensorDtypes.betaT == \"float16\" and tensorDtypes.biasT == \"float16\" and dim(shapes.biasT, 0) == hiddenSize)", "statsContract": "statsRequested and coreContract and f16Ok(dtypes.T) and (not present.biasT or (ranks.biasT == 1 and dim(shapes.biasT, 0) == hiddenSize)) and (not present.residualT or sameShape(shapes.residualT, shapes.inputT)) and (not present.betaT or (ranks.betaT == 1 and dim(shapes.betaT, 0) == hiddenSize))" }, "bindings": { "input": { "arg": "inputT", "elementType": "$vectorScalar" }, "skip": { "arg": "skipT", "elementType": "$vectorScalar" }, "gamma": { "arg": "gammaT", "elementType": "$vectorScalar", "length": "$HIDDEN_LEN" }, "beta": { "arg": "betaT", "elementType": "$vectorScalar", "length": "$HIDDEN_LEN" }, "output": { "arg": "outputT", "elementType": "$vectorScalar" }, "bias": { "arg": "biasT", "elementType": "$vectorScalar", "length": "$HIDDEN_LEN" }, "input_skip_bias_sum": { "arg": "residualT", "elementType": "$vectorScalar" }, "params_main": { "name": "params", "struct": [ { "name": "rows", "type": "u32", "value": "rowCount" }, { "name": "rowStride", "type": "u32", "value": "max(1, min(rowCount, min(device.limits.maxComputeWorkgroupsPerDimension, 65535)))" }, { "name": "epsilon", "type": "f32", "value": "attrs.epsilon" } ] }, "input_main": { "arg": "inputT", "name": "input", "elementType": "$scalar" }, "skip_main": { "arg": "skipT", "name": "skip", "elementType": "$scalar" }, "bias_main": { "arg": "biasT", "name": "bias", "elementType": "$scalar", "length": "$HIDDEN_LEN" }, "gamma_main": { "arg": "gammaT", "name": "gamma", "elementType": "$scalar", "length": "$HIDDEN_LEN" }, "beta_main": { "arg": "betaT", "name": "beta", "elementType": "$scalar", "length": "$HIDDEN_LEN" }, "output_main": { "arg": "outputT", "name": "output", "elementType": "$scalar" }, "input_skip_bias_sum_main": { "arg": "residualT", "name": "input_skip_bias_sum", "elementType": "$scalar" }, "params__uniform": { "name": "params", "struct": [ { "name": "rows", "type": "u32", "value": "rowCount" }, { "name": "epsilon", "type": "f32", "value": "attrs.epsilon" } ] }, "mean": { "arg": "meanT", "elementType": "f32" }, "inv_std_var": { "arg": "invStdT", "elementType": "f32" }, "row_stats": { "scratch": "rowStats", "elementType": "vec2<f32>" }, "row_stats_read": { "scratch": "rowStats", "name": "row_stats", "buffer": "read-only-storage", "elementType": "vec2<f32>" }, "params_stats": { "name": "params", "struct": [{ "name": "rows", "type": "u32", "value": "rowCount" }] } }, "variants": [ { "id": "hidden1_f32_no_beta", "priority": 20, "when": ["f32_no_beta_output_contract", "hiddenSize == 1", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": false, "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": false, "scalar": "dtypes.T", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Hidden1", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["gamma_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "hidden1_f32_beta", "priority": 20, "when": ["(f32_beta_no_bias_output_only_contract or f32_beta_bias_output_only_contract)", "hiddenSize == 1", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": false, "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": false, "scalar": "dtypes.T", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Hidden1", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["gamma_main", "beta_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "hidden1_f16_no_beta", "priority": 20, "when": ["f16_no_beta_output_contract", "hiddenSize == 1", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": false, "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": false, "scalar": "dtypes.T", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Hidden1", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["gamma_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "hidden1_f16_beta", "priority": 20, "when": ["(f16_beta_no_bias_output_only_contract or f16_beta_bias_output_only_contract)", "hiddenSize == 1", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": false, "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": false, "scalar": "dtypes.T", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Hidden1", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["gamma_main", "beta_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "beta_output_only_vec4_broadcast", "priority": 19, "when": ["broadcastOutputOnlyContract", "broadcastResourcesFit", "broadcastDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f32>\"", "HIDDEN_LEN": "broadcastHiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.BroadcastSkip", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": false, "hasBeta": true, "writeResidualSum": false, "broadcastSkip": true, "hidden": "broadcastHiddenSize", "hiddenVec": "broadcastHiddenSize / 4", "wg": "broadcastSkipWgVec4", "vecType": "\"vec4<f32>\"", "useSubgroups": "hasSubgroups" }, "bindings": [ "input", "skip", "gamma", "beta", "output", { "name": "params", "struct": [ { "name": "rows", "type": "u32", "value": "dim(shapes.inputT, 0) * dim(shapes.inputT, 1)" }, { "name": "rowStride", "type": "u32", "value": "max(1, min(broadcastRows, min(device.limits.maxComputeWorkgroupsPerDimension, 65535)))" }, { "name": "epsilon", "type": "f32", "value": "attrs.epsilon" }, { "name": "skipRows", "type": "u32", "value": "numel(shapes.skipT) / broadcastHiddenSize" } ] } ], "dispatch": { "x": "min(broadcastRows, 65535)", "y": "ceilDiv(broadcastRows, 65535)", "z": 1 } } ] }, { "id": "beta_bias_vec4", "priority": 15, "when": ["f32_beta_bias_residual_contract", "vec4Aligned", "hasSubgroups or \"bias\" == \"bias\" or portableWideExecution", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f32>\"", "hasBias": "\"bias\" == \"bias\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "normalize", "name": "SkipLayerNormalization.Vec4.Normalize", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBeta": true, "writeResidualSum": true, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f32>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "bias", "gamma", "beta", "output", "input_skip_bias_sum", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "beta_bias_row", "priority": 5, "when": ["f32_beta_bias_residual_contract", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "useSubgroups": "hasSubgroups", "hasBeta": true, "writeResidualSum": true, "hasBias": "\"bias\" == \"bias\"", "scalar": "\"f32\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "normalize", "name": "SkipLayerNormalization.Row.Normalize", "shader": "norm-skip-row.wgsl.jinja", "derive": { "writeResidualSum": true }, "bindings": ["input_main", "skip_main", "bias_main", "gamma_main", "beta_main", "output_main", "input_skip_bias_sum_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "beta_no_bias_vec4", "priority": 20, "when": ["f32_beta_no_bias_residual_contract", "vec4Aligned", "hasSubgroups or portableWideExecution", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f32>\"", "hasBias": "\"no_bias\" == \"bias\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Vec4", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBeta": true, "writeResidualSum": true, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f32>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "gamma", "beta", "output", "input_skip_bias_sum", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "beta_no_bias_row", "priority": 10, "when": ["f32_beta_no_bias_residual_contract", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "useSubgroups": "hasSubgroups", "hasBeta": true, "writeResidualSum": true, "hasBias": "\"no_bias\" == \"bias\"", "scalar": "\"f32\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Row", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "output_main", "input_skip_bias_sum_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "beta_bias_vec4_f16", "priority": 21, "when": ["f16_beta_bias_residual_contract", "vec4Aligned", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f16>\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Vec4", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": true, "hasBeta": true, "writeResidualSum": true, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f16>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "bias", "gamma", "beta", "output", "input_skip_bias_sum", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "no_beta_output_only_vec4", "priority": 20, "when": ["f32_no_beta_output_contract", "vec4Aligned", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f32>\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.NoBetaOutputOnly.Vec4", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f32>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "gamma", "output", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "no_beta_output_only_row", "priority": 10, "when": ["f32_no_beta_output_contract", "normResourcesFit", "rowDispatchFits", "hiddenSize != 1", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": "hasSubgroups", "scalar": "\"f32\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.NoBetaOutputOnly.Row", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "no_beta_output_only_vec4_f16", "priority": 20, "when": ["f16_no_beta_output_contract", "vec4Aligned", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f16>\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.NoBetaOutputOnly.Vec4.F16", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f16>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "gamma", "output", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "no_beta_output_only_row_f16", "priority": 10, "when": ["f16_no_beta_output_contract", "normResourcesFit", "rowDispatchFits", "hiddenSize != 1", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": "hasSubgroups", "scalar": "\"f16\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.NoBetaOutputOnly.Row.F16", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "beta_no_bias_output_only_vec4", "priority": 20, "when": ["f32_beta_no_bias_output_only_contract", "vec4Aligned", "hasSubgroups or portableWideExecution", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f32>\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Vec4", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f32>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "gamma", "beta", "output", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "beta_no_bias_output_only_row", "priority": 10, "when": ["f32_beta_no_bias_output_only_contract", "normResourcesFit", "rowDispatchFits", "hiddenSize != 1", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": "hasSubgroups", "scalar": "\"f32\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Row", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "beta_no_bias_output_only_vec4_f16", "priority": 20, "when": ["f16_beta_no_bias_output_only_contract", "vec4Aligned", "hasSubgroups or portableWideExecution", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f16>\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Vec4.F16", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f16>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "gamma", "beta", "output", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "beta_no_bias_output_only_row_f16", "priority": 10, "when": ["f16_beta_no_bias_output_only_contract", "normResourcesFit", "rowDispatchFits", "hiddenSize != 1", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": "hasSubgroups", "scalar": "\"f16\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Row.F16", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "beta_bias_output_only_vec4", "priority": 20, "when": ["f32_beta_bias_output_only_contract", "vec4Aligned", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f32>\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Vec4", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f32>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "gamma", "beta", "bias", "output", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "beta_bias_output_only_row", "priority": 10, "when": ["f32_beta_bias_output_only_contract", "normResourcesFit", "rowDispatchFits", "hiddenSize != 1", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": "hasSubgroups", "scalar": "\"f32\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Row", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "bias_main", "gamma_main", "beta_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "beta_bias_output_only_vec4_f16", "priority": 20, "when": ["f16_beta_bias_output_only_contract", "vec4Aligned", "normResourcesFit", "rowDispatchFits", "not present.meanT and not present.invStdT"], "derive": { "vectorScalar": "\"vec4<f16>\"", "HIDDEN_LEN": "hiddenSize / 4" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Vec4.F16", "shader": "norm-skip-row-vec4.wgsl.jinja", "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "hidden": "hiddenSize", "hiddenVec": "hiddenSize / 4", "wg": "skipWgVec4", "vecType": "\"vec4<f16>\"", "useSubgroups": "hasSubgroups" }, "bindings": ["input", "skip", "gamma", "beta", "bias", "output", "params_main"], "dispatch": { "x": "min(rowCount, 65535)", "y": "ceilDiv(rowCount, 65535)", "z": 1 } } ] }, { "id": "beta_bias_output_only_row_f16", "priority": 10, "when": ["f16_beta_bias_output_only_contract", "normResourcesFit", "rowDispatchFits", "hiddenSize != 1", "not present.meanT and not present.invStdT"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": false, "useSubgroups": "hasSubgroups", "scalar": "\"f16\"", "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize" }, "passes": [ { "id": "main", "name": "SkipLayerNormalization.Row.F16", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "bias_main", "gamma_main", "beta_main", "output_main", "params__uniform"], "dispatch": { "x": "min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "y": "ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)", "z": 1 } } ] }, { "id": "stats_mean_plain", "when": ["statsContract", "present.meanT", "not present.invStdT", "not present.biasT", "not present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_mean_residual", "when": ["statsContract", "present.meanT", "not present.invStdT", "not present.biasT", "not present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "input_skip_bias_sum_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_mean_beta", "when": ["statsContract", "present.meanT", "not present.invStdT", "not present.biasT", "present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_mean_beta_residual", "when": ["statsContract", "present.meanT", "not present.invStdT", "not present.biasT", "present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "input_skip_bias_sum_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_mean_bias", "when": ["statsContract", "present.meanT", "not present.invStdT", "present.biasT", "not present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_mean_bias_residual", "when": ["statsContract", "present.meanT", "not present.invStdT", "present.biasT", "not present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "input_skip_bias_sum_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_mean_bias_beta", "when": ["statsContract", "present.meanT", "not present.invStdT", "present.biasT", "present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "beta_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_mean_bias_beta_residual", "when": ["statsContract", "present.meanT", "not present.invStdT", "present.biasT", "present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "beta_main", "input_skip_bias_sum_main", "output_main", "mean", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_plain", "when": ["statsContract", "not present.meanT", "present.invStdT", "not present.biasT", "not present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_residual", "when": ["statsContract", "not present.meanT", "present.invStdT", "not present.biasT", "not present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "input_skip_bias_sum_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_beta", "when": ["statsContract", "not present.meanT", "present.invStdT", "not present.biasT", "present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_beta_residual", "when": ["statsContract", "not present.meanT", "present.invStdT", "not present.biasT", "present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "input_skip_bias_sum_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_bias", "when": ["statsContract", "not present.meanT", "present.invStdT", "present.biasT", "not present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_bias_residual", "when": ["statsContract", "not present.meanT", "present.invStdT", "present.biasT", "not present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "input_skip_bias_sum_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_bias_beta", "when": ["statsContract", "not present.meanT", "present.invStdT", "present.biasT", "present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "beta_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_inv_bias_beta_residual", "when": ["statsContract", "not present.meanT", "present.invStdT", "present.biasT", "present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": false }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "beta_main", "input_skip_bias_sum_main", "output_main", "inv_std_var", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } } ], "intermediates": [] }, { "id": "stats_both_plain", "when": ["statsContract", "present.meanT", "present.invStdT", "not present.biasT", "not present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] }, { "id": "stats_both_residual", "when": ["statsContract", "present.meanT", "present.invStdT", "not present.biasT", "not present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "input_skip_bias_sum_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] }, { "id": "stats_both_beta", "when": ["statsContract", "present.meanT", "present.invStdT", "not present.biasT", "present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] }, { "id": "stats_both_beta_residual", "when": ["statsContract", "present.meanT", "present.invStdT", "not present.biasT", "present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "beta_main", "input_skip_bias_sum_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] }, { "id": "stats_both_bias", "when": ["statsContract", "present.meanT", "present.invStdT", "present.biasT", "not present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] }, { "id": "stats_both_bias_residual", "when": ["statsContract", "present.meanT", "present.invStdT", "present.biasT", "not present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "input_skip_bias_sum_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] }, { "id": "stats_both_bias_beta", "when": ["statsContract", "present.meanT", "present.invStdT", "present.biasT", "present.betaT", "not present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "beta_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] }, { "id": "stats_both_bias_beta_residual", "when": ["statsContract", "present.meanT", "present.invStdT", "present.biasT", "present.betaT", "present.residualT", "normResourcesFit", "rowDispatchFits"], "derive": { "simplified": false, "hasBias": "present.biasT", "hasBeta": "present.betaT", "writeResidualSum": "present.residualT", "writeMean": "present.meanT", "writeInvStd": "present.invStdT", "scalar": "dtypes.T", "useSubgroups": false, "workgroupSize": "skipWg", "HIDDEN_LEN": "hiddenSize", "packedStatistics": true }, "passes": [ { "id": "main", "shader": "norm-skip-row.wgsl.jinja", "bindings": ["input_main", "skip_main", "gamma_main", "bias_main", "beta_main", "input_skip_bias_sum_main", "output_main", "row_stats", "params__uniform"], "dispatch": { "x": "min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "y": "ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)", "z": 1 } }, { "id": "statistics", "shader": "norm-stats-copy.wgsl.jinja", "derive": { "workgroupSize": 64 }, "bindings": ["row_stats_read", "mean", "inv_std_var", "params_stats"], "dispatch": { "x": "min(ceilDiv((rowCount), (workgroupSize)), 65535)", "y": "ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)", "z": 1 } } ], "intermediates": [{ "id": "rowStats", "dtype": "float32", "shape": "[rowCount, 2]" }] } ]}{"domain":"com.microsoft","name":"SkipLayerNormalization","sinceVersion":1,"inputs":{"inputT":{"onnx":"input","dtype":"T"},"skipT":{"onnx":"skip","dtype":"T"},"gammaT":{"onnx":"gamma","dtype":"T","rank":1},"betaT":{"onnx":"beta","dtype":"T","rank":1,"optional":true},"biasT":{"onnx":"bias","dtype":"T","rank":1,"optional":true}},"outputs":{"outputT":{"onnx":"output","dtype":"T","rank":"ranks.inputT","shape":"shapes.inputT"},"meanT":{"onnx":"mean","dtype":"U","optional":true,"rank":"ranks.inputT","shape":"prefix(shapes.inputT, ranks.inputT - 1) + [1]"},"invStdT":{"onnx":"inv_std_var","dtype":"U","optional":true,"rank":"ranks.inputT","shape":"prefix(shapes.inputT, ranks.inputT - 1) + [1]"},"residualT":{"onnx":"input_skip_bias_sum","dtype":"T","rank":"ranks.inputT","optional":true,"shape":"shapes.inputT"}},"attributes":{"epsilon":{"default":9.999999960041972e-13}},"typeConstraints":{"T":["float32","float16"],"U":["float32"]},"tunables":{"MAX_WORKGROUP_SIZE":{"default":256}},"derive":{"rowCount":"numel(shapes.inputT) / max(1, dim(shapes.inputT, -1))","hiddenSize":"dim(shapes.inputT, -1)","skipWg":"max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX)) if hiddenSize == 1 else max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX, pow2ceil(hiddenSize)))","skipWgVec4":"max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX, pow2ceil(ceilDiv(hiddenSize, 4))))","rowDispatchFits":"rowCount <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)","normResourcesFit":"skipWg * 8 <= device.limits.maxComputeWorkgroupStorageSize and skipWgVec4 * 8 <= device.limits.maxComputeWorkgroupStorageSize","epsilonOk":"attrs.epsilon >= 0","coreContract":"epsilonOk and (ranks.inputT == 2 or ranks.inputT == 3) and ranks.skipT == ranks.inputT and ranks.gammaT == 1 and ranks.outputT == ranks.inputT and sameShape(shapes.inputT, shapes.skipT) and sameShape(shapes.outputT, shapes.inputT) and dim(shapes.inputT, -1) > 0 and dim(shapes.gammaT, 0) == dim(shapes.inputT, -1)","residualOutputContract":"present.residualT and sameShape(shapes.residualT, shapes.inputT)","outputOnlyContract":"not present.residualT","f32MainDtypes":"tensorDtypes.inputT == \"float32\" and tensorDtypes.skipT == \"float32\" and tensorDtypes.gammaT == \"float32\" and tensorDtypes.outputT == \"float32\"","f16MainDtypes":"tensorDtypes.inputT == \"float16\" and tensorDtypes.skipT == \"float16\" and tensorDtypes.gammaT == \"float16\" and tensorDtypes.outputT == \"float16\"","f32ResidualDtypes":"f32MainDtypes and tensorDtypes.residualT == \"float32\" if present.residualT else false","f16ResidualDtypes":"f16MainDtypes and tensorDtypes.residualT == \"float16\" if present.residualT else false","vec4Aligned":"dim(shapes.inputT, -1) % 4 == 0","hasSubgroups":"device.features.has(\"subgroups\") and device.wgslLanguageFeatures.has(\"subgroup_id\")","hasF16":"device.features.has(\"shader-f16\")","statsRequested":"present.meanT or present.invStdT","portableWideExecution":"not has(device.adapterInfo, \"subgroupMinSize\") or device.adapterInfo.subgroupMinSize >= 32","broadcastRows":"dim(shapes.inputT, 0) * dim(shapes.inputT, 1)","broadcastHiddenSize":"dim(shapes.inputT, 2)","broadcastSkipWgVec4":"max(1, min(tunables.MAX_WORKGROUP_SIZE, device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX, pow2ceil(ceilDiv(broadcastHiddenSize, 4))))","broadcastDispatchFits":"broadcastRows <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)","broadcastResourcesFit":"broadcastSkipWgVec4 * 8 <= device.limits.maxComputeWorkgroupStorageSize","broadcastSkipShapeOk":"(ranks.skipT == 2 and dim(shapes.skipT, 0) == dim(shapes.inputT, 1) and dim(shapes.skipT, 1) == dim(shapes.inputT, 2)) or (ranks.skipT == 3 and ((dim(shapes.skipT, 0) == 1 and dim(shapes.skipT, 1) == dim(shapes.inputT, 1) and dim(shapes.skipT, 2) == dim(shapes.inputT, 2)) or sameShape(shapes.skipT, shapes.inputT)))","broadcastOutputOnlyContract":"false if ranks.inputT != 3 or not present.betaT else (epsilonOk and not present.biasT and not present.residualT and dim(shapes.inputT, 2) % 4 == 0 and broadcastSkipShapeOk and ranks.gammaT == 1 and ranks.betaT == 1 and ranks.outputT == 3 and tensorDtypes.inputT == \"float32\" and tensorDtypes.skipT == \"float32\" and tensorDtypes.gammaT == \"float32\" and tensorDtypes.betaT == \"float32\" and tensorDtypes.outputT == \"float32\" and dim(shapes.inputT, 2) > 0 and dim(shapes.gammaT, 0) == dim(shapes.inputT, 2) and dim(shapes.betaT, 0) == dim(shapes.inputT, 2) and sameShape(shapes.outputT, shapes.inputT))","fusedContract":"coreContract and (f32MainDtypes or (hasF16 and f16MainDtypes)) and (not present.betaT or (ranks.betaT == 1 and dim(shapes.betaT, 0) == hiddenSize and tensorDtypes.betaT == tensorDtypes.inputT)) and (not present.biasT or (present.betaT and ranks.biasT == 1 and dim(shapes.biasT, 0) == hiddenSize and tensorDtypes.biasT == tensorDtypes.inputT)) and (outputOnlyContract or (present.betaT and residualOutputContract and (f32ResidualDtypes or f16ResidualDtypes)))","statsContract":"statsRequested and coreContract and f16Ok(dtypes.T) and (not present.biasT or (ranks.biasT == 1 and dim(shapes.biasT, 0) == hiddenSize)) and (not present.residualT or sameShape(shapes.residualT, shapes.inputT)) and (not present.betaT or (ranks.betaT == 1 and dim(shapes.betaT, 0) == hiddenSize))"},"bindings":{"input":{"arg":"inputT","elementType":"$vectorScalar"},"skip":{"arg":"skipT","elementType":"$vectorScalar"},"gamma":{"arg":"gammaT","elementType":"$vectorScalar","length":"$HIDDEN_LEN"},"beta":{"arg":"betaT","elementType":"$vectorScalar","length":"$HIDDEN_LEN","when":"present.betaT"},"output":{"arg":"outputT","elementType":"$vectorScalar"},"bias_before_gamma":{"arg":"biasT","name":"bias","elementType":"$vectorScalar","length":"$HIDDEN_LEN","when":"present.biasT and present.residualT"},"bias_after_beta":{"arg":"biasT","name":"bias","elementType":"$vectorScalar","length":"$HIDDEN_LEN","when":"present.biasT and not present.residualT"},"input_skip_bias_sum":{"arg":"residualT","elementType":"$vectorScalar","when":"present.residualT"},"params_main":{"name":"params","struct":[{"name":"rows","type":"u32","value":"rowCount"},{"name":"rowStride","type":"u32","value":"max(1, min(rowCount, min(device.limits.maxComputeWorkgroupsPerDimension, 65535)))"},{"name":"epsilon","type":"f32","value":"attrs.epsilon"}]},"input_main":{"arg":"inputT","name":"input","elementType":"$scalar"},"skip_main":{"arg":"skipT","name":"skip","elementType":"$scalar"},"bias_main":{"arg":"biasT","name":"bias","elementType":"$scalar","length":"$HIDDEN_LEN","when":"present.biasT"},"gamma_main":{"arg":"gammaT","name":"gamma","elementType":"$scalar","length":"$HIDDEN_LEN"},"beta_main":{"arg":"betaT","name":"beta","elementType":"$scalar","length":"$HIDDEN_LEN","when":"present.betaT"},"output_main":{"arg":"outputT","name":"output","elementType":"$scalar"},"input_skip_bias_sum_main":{"arg":"residualT","name":"input_skip_bias_sum","elementType":"$scalar","when":"present.residualT"},"params__uniform":{"name":"params","struct":[{"name":"rows","type":"u32","value":"rowCount"},{"name":"epsilon","type":"f32","value":"attrs.epsilon"}]},"mean":{"arg":"meanT","elementType":"f32"},"inv_std_var":{"arg":"invStdT","elementType":"f32"},"mean_main":{"arg":"meanT","name":"mean","elementType":"f32","when":"present.meanT and not present.invStdT"},"inv_std_var_main":{"arg":"invStdT","name":"inv_std_var","elementType":"f32","when":"present.invStdT and not present.meanT"},"row_stats":{"scratch":"rowStats","elementType":"vec2<f32>","when":"present.meanT and present.invStdT"},"row_stats_read":{"scratch":"rowStats","name":"row_stats","buffer":"read-only-storage","elementType":"vec2<f32>"},"params_stats":{"name":"params","struct":[{"name":"rows","type":"u32","value":"rowCount"}]}},"variants":[{"id":"row","priority":10,"when":["fusedContract","f32MainDtypes or not present.residualT","normResourcesFit","rowDispatchFits","not statsRequested"],"derive":{"simplified":false,"useSubgroups":"hasSubgroups","hasBeta":"present.betaT","hasBias":"present.biasT","writeResidualSum":"present.residualT","scalar":"dtypes.T","workgroupSize":"skipWg","HIDDEN_LEN":"hiddenSize"},"passes":[{"id":"main","name":"SkipLayerNormalization.Row","shader":"norm-skip-row.wgsl.jinja","bindings":["input_main","skip_main","bias_main","gamma_main","beta_main","output_main","input_skip_bias_sum_main","params__uniform"],"dispatch":{"x":"min(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)","y":"ceilDiv(ceilDiv((rowCount * (1 if hiddenSize == 1 else skipWg)), (skipWg)), 65535)","z":1}}]},{"id":"beta_output_only_vec4_broadcast","priority":19,"when":["broadcastOutputOnlyContract","broadcastResourcesFit","broadcastDispatchFits","not present.meanT and not present.invStdT"],"derive":{"vectorScalar":"\"vec4<f32>\"","HIDDEN_LEN":"broadcastHiddenSize / 4"},"passes":[{"id":"main","name":"SkipLayerNormalization.BroadcastSkip","shader":"norm-skip-row-vec4.wgsl.jinja","derive":{"simplified":false,"hasBias":false,"hasBeta":true,"writeResidualSum":false,"broadcastSkip":true,"hidden":"broadcastHiddenSize","hiddenVec":"broadcastHiddenSize / 4","wg":"broadcastSkipWgVec4","vecType":"\"vec4<f32>\"","useSubgroups":"hasSubgroups"},"bindings":["input","skip","gamma","beta","output",{"name":"params","struct":[{"name":"rows","type":"u32","value":"dim(shapes.inputT, 0) * dim(shapes.inputT, 1)"},{"name":"rowStride","type":"u32","value":"max(1, min(broadcastRows, min(device.limits.maxComputeWorkgroupsPerDimension, 65535)))"},{"name":"epsilon","type":"f32","value":"attrs.epsilon"},{"name":"skipRows","type":"u32","value":"numel(shapes.skipT) / broadcastHiddenSize"}]}],"dispatch":{"x":"min(broadcastRows, 65535)","y":"ceilDiv(broadcastRows, 65535)","z":1}}]},{"id":"vec4","priority":20,"when":["fusedContract","vec4Aligned","f32MainDtypes or present.biasT or not present.residualT","present.biasT or not present.betaT or hasSubgroups or portableWideExecution","normResourcesFit","rowDispatchFits","not statsRequested"],"derive":{"vectorScalar":"\"vec4<f16>\" if dtypes.T == \"f16\" else \"vec4<f32>\"","HIDDEN_LEN":"hiddenSize / 4"},"passes":[{"id":"main","name":"SkipLayerNormalization.Vec4","shader":"norm-skip-row-vec4.wgsl.jinja","derive":{"simplified":false,"hasBias":"present.biasT","hasBeta":"present.betaT","writeResidualSum":"present.residualT","hidden":"hiddenSize","hiddenVec":"hiddenSize / 4","wg":"skipWgVec4","vecType":"vectorScalar","useSubgroups":"hasSubgroups"},"bindings":["input","skip","bias_before_gamma","gamma","beta","bias_after_beta","output","input_skip_bias_sum","params_main"],"dispatch":{"x":"min(rowCount, 65535)","y":"ceilDiv(rowCount, 65535)","z":1}}]},{"id":"stats","when":["statsContract","normResourcesFit","rowDispatchFits"],"derive":{"simplified":false,"hasBias":"present.biasT","hasBeta":"present.betaT","writeResidualSum":"present.residualT","writeMean":"present.meanT","writeInvStd":"present.invStdT","scalar":"dtypes.T","useSubgroups":false,"workgroupSize":"skipWg","HIDDEN_LEN":"hiddenSize","packedStatistics":"present.meanT and present.invStdT"},"intermediates":[{"id":"rowStats","dtype":"float32","shape":"[rowCount, 2]"}],"passes":[{"id":"main","shader":"norm-skip-row.wgsl.jinja","bindings":["input_main","skip_main","gamma_main","bias_main","beta_main","input_skip_bias_sum_main","output_main","mean_main","inv_std_var_main","row_stats","params__uniform"],"dispatch":{"x":"min(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)","y":"ceilDiv(ceilDiv(rowCount, skipWg) if hiddenSize == 1 else rowCount, 65535)","z":1}},{"repeat":{"index":"statsCopy","count":"1 if present.meanT and present.invStdT else 0"},"passes":[{"id":"statistics","shader":"norm-stats-copy.wgsl.jinja","derive":{"workgroupSize":64},"bindings":["row_stats_read","mean","inv_std_var","params_stats"],"dispatch":{"x":"min(ceilDiv((rowCount), (workgroupSize)), 65535)","y":"ceilDiv(ceilDiv((rowCount), (workgroupSize)), 65535)","z":1}}]}]}]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869701{ "name": "com.microsoft.SkipLayerNormalization", "id": "_com_microsoft_skiplayernormalization_webgpu_a30f1f2", "version": 1, "license": "Apache-2.0", "backend": { "type": "webgpu" }, "digest": { "algorithm": "sha256", "files": { "bench.json": "cVSe9BmYyynkTmGaCfti3+3as2tY8s7SiHcDUGZXadQ=", "manifest.json": "eBeukaRPaePto8cDuxf/pVi95UUFHU+jR4Tcc4/FFh4=", "norm-skip-row-vec4.wgsl.jinja": "hpoa1+W36ADP2AlqvZAoWFHCZPTBrUIlgVIQXE98oTE=", "norm-skip-row.wgsl.jinja": "LOw1CZFwolmaeaXpWSTi8ToiXzTfvJDoaapF2N6a0x4=", "norm-stats-copy.wgsl.jinja": "4PNrRNFbMWP9csH7RrxSvJuAGSn5aDfZZPw/IZEVmjU=", "test.json": "upshAVlCpYOJn3G1M4TGhznjHzx8ybo8uae8zkB932s=" } }, "provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } }, "webgpu": { "manifestSpec": "2.1", "variants": { "hidden1_f32_no_beta": ["norm-skip-row.wgsl.jinja"], "hidden1_f32_beta": ["norm-skip-row.wgsl.jinja"], "hidden1_f16_no_beta": ["norm-skip-row.wgsl.jinja"], "hidden1_f16_beta": ["norm-skip-row.wgsl.jinja"], "beta_output_only_vec4_broadcast": ["norm-skip-row-vec4.wgsl.jinja"], "beta_bias_vec4": ["norm-skip-row-vec4.wgsl.jinja"], "beta_bias_row": ["norm-skip-row.wgsl.jinja"], "beta_no_bias_vec4": ["norm-skip-row-vec4.wgsl.jinja"], "beta_no_bias_row": ["norm-skip-row.wgsl.jinja"], "beta_bias_vec4_f16": ["norm-skip-row-vec4.wgsl.jinja"], "no_beta_output_only_vec4": ["norm-skip-row-vec4.wgsl.jinja"], "no_beta_output_only_row": ["norm-skip-row.wgsl.jinja"], "no_beta_output_only_vec4_f16": ["norm-skip-row-vec4.wgsl.jinja"], "no_beta_output_only_row_f16": ["norm-skip-row.wgsl.jinja"], "beta_no_bias_output_only_vec4": ["norm-skip-row-vec4.wgsl.jinja"], "beta_no_bias_output_only_row": ["norm-skip-row.wgsl.jinja"], "beta_no_bias_output_only_vec4_f16": ["norm-skip-row-vec4.wgsl.jinja"], "beta_no_bias_output_only_row_f16": ["norm-skip-row.wgsl.jinja"], "beta_bias_output_only_vec4": ["norm-skip-row-vec4.wgsl.jinja"], "beta_bias_output_only_row": ["norm-skip-row.wgsl.jinja"], "beta_bias_output_only_vec4_f16": ["norm-skip-row-vec4.wgsl.jinja"], "beta_bias_output_only_row_f16": ["norm-skip-row.wgsl.jinja"], "stats_mean_plain": ["norm-skip-row.wgsl.jinja"], "stats_mean_residual": ["norm-skip-row.wgsl.jinja"], "stats_mean_beta": ["norm-skip-row.wgsl.jinja"], "stats_mean_beta_residual": ["norm-skip-row.wgsl.jinja"], "stats_mean_bias": ["norm-skip-row.wgsl.jinja"], "stats_mean_bias_residual": ["norm-skip-row.wgsl.jinja"], "stats_mean_bias_beta": ["norm-skip-row.wgsl.jinja"], "stats_mean_bias_beta_residual": ["norm-skip-row.wgsl.jinja"], "stats_inv_plain": ["norm-skip-row.wgsl.jinja"], "stats_inv_residual": ["norm-skip-row.wgsl.jinja"], "stats_inv_beta": ["norm-skip-row.wgsl.jinja"], "stats_inv_beta_residual": ["norm-skip-row.wgsl.jinja"], "stats_inv_bias": ["norm-skip-row.wgsl.jinja"], "stats_inv_bias_residual": ["norm-skip-row.wgsl.jinja"], "stats_inv_bias_beta": ["norm-skip-row.wgsl.jinja"], "stats_inv_bias_beta_residual": ["norm-skip-row.wgsl.jinja"], "stats_both_plain": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"], "stats_both_residual": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"], "stats_both_beta": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"], "stats_both_beta_residual": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"], "stats_both_bias": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"], "stats_both_bias_residual": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"], "stats_both_bias_beta": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"], "stats_both_bias_beta_residual": ["norm-skip-row.wgsl.jinja", "norm-stats-copy.wgsl.jinja"] } }}{"name":"com.microsoft.SkipLayerNormalization","id":"_com_microsoft_skiplayernormalization_webgpu_4e77e0d","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"SWSQFoxcME16BoI46yhBO4WH7c+z3Sgw6IifTc/vS4Y=","manifest.json":"2HMasjYK8IQoX3ktVwQyyUHTGfHyx0IkbhI0iw7P7/Q=","norm-skip-row-vec4.wgsl.jinja":"x2hFBTHo8BUEpvPp24SDSWk2vmM2vKBtPCNDwwPoPJI=","norm-skip-row.wgsl.jinja":"7nDNFUalZu/QwY/29E0y9NlKZnYCJEkI+BAtm/HTzVc=","norm-stats-copy.wgsl.jinja":"Dss4qJTpAPjQtVp3OvI/LEbiAW/QNXb6aUPDp/7s9v8=","test.json":"qlIirchgkSYwzWTqjp2eXOvTyJgnYtMptlBuTkFVePM="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}1 unmodified line23455678891011121314 unmodified lines2829302931323332343536373839404135424344454640474849505145525354485556575813 unmodified lines727374687570767778798019 unmodified lines100101102961031041051061 unmodified line{% if op == "max" or op == "min" %}{{ a }}[{{ idx }}] = {{ op }}({{ a }}[{{ idx }}], {{ a }}[{{ idx }} + {{ svar }}]);{% else %}{{ a }}[{{ idx }}] = {{ a }}[{{ idx }}] {{ "*" if op == "prod" else "+" }} {{ a }}[{{ idx }} + {{ svar }}];{% endif %}{% endmacro %}{% macro wgsl_tree_fold(arrays, op="add", idx="lid", wg="WORKGROUP_SIZE", svar="stride", typed=false, form="tail", breakInline=false, bodyInline=false, barrierFirst=false, reuse=false) %}{% macro wgsl_tree_fold(arrays, op="add", idx="lid", wg="WORKGROUP_SIZE", svar="stride", typed=false, form="tail", barrierFirst=false, reuse=false) %} var {{ svar }}{{ ": u32 " if typed else " " }}= {{ wg }} / 2u; loop { if ({{ svar }} == 0u) { break; } if ({{ svar }} == 0u) { break; } if ({{ idx }} < {{ svar }}) {{% for a in arrays %} {{ wgsl_tree_fold_stmt(a, op, idx, svar) }}14 unmodified lines
var<workgroup> sg_partials: array<vec2<f32>, WG>;
fn reduce_pair(value: vec2<f32>{% if useSubgroups %}, sg_lane: u32, sg_id: u32, num_sg: u32{% else %}, tid: u32{% endif %}) -> vec2<f32> {fn reduce_pair(value: vec2<f32>{% if useSubgroups %}, sg_id: u32, num_sg: u32, sg_size: u32{% else %}, tid: u32{% endif %}) -> vec2<f32> {{% if useSubgroups %} let s = vec2<f32>(subgroupAdd(value.x), subgroupAdd(value.y)); if (num_sg == 1u) { // Chrome on Qualcomm Adreno reports num_subgroups = 1 for a workgroup that spans several subgroups. // The reported subgroup count can be too low. Raise it to the fewest subgroups the workgroup can occupy, so an // under-reported count can neither take the one-subgroup return nor cut the fold short; a conformant count // always wins. let fold_count = max(num_sg, (WG + sg_size - 1u) >> firstTrailingBit(sg_size)); if (fold_count == 1u) { return s; } if (sg_lane == 0u) { if (subgroupElect()) { sg_partials[sg_id] = s; } workgroupBarrier(); var total = vec2<f32>(0.0, 0.0); for (var i = 0u; i < num_sg; i = i + 1u) { for (var i = 0u; i < fold_count; i = i + 1u) { total = total + sg_partials[i]; } return total;{% else %} // No-subgroup tier: workgroup barrier tree-reduction (WG is a power of two). // Without subgroups: workgroup barrier tree-reduction (WG is a power of two). sg_partials[tid] = value; workgroupBarrier();{{ wgsl_tree_fold(["sg_partials"], idx="tid", wg="WG", form="head", breakInline=true) }}{{ wgsl_tree_fold(["sg_partials"], idx="tid", wg="WG", form="head") }} return sg_partials[0];{% endif %}}13 unmodified linesfn main( @builtin(workgroup_id) wg_id: vec3<u32>, @builtin(local_invocation_id) lid: vec3<u32>{% if useSubgroups %}, @builtin(subgroup_invocation_id) sg_lane: u32, @builtin(subgroup_id) sg_id: u32, @builtin(num_subgroups) num_sg: u32{% endif %} @builtin(num_subgroups) num_sg: u32, @builtin(subgroup_size) sg_size: u32{% endif %}) { let row = wg_id.x + wg_id.y * params.rowStride; if (row >= params.rows) {19 unmodified lines acc.y = acc.y + dot(d, d); }
let totals = reduce_pair(acc{% if useSubgroups %}, sg_lane, sg_id, num_sg{% else %}, tid{% endif %}); let totals = reduce_pair(acc{% if useSubgroups %}, sg_id, num_sg, sg_size{% else %}, tid{% endif %}); let mean_d = totals.x / f32(HIDDEN); let variance = max(totals.y / f32(HIDDEN) - mean_d * mean_d, 0.0); let row_inv = inverseSqrt(variance + params.epsilon);1 unmodified line2345567815 unmodified lines24252627272928293031323336343538363738394041424341444546474846495051527 unmodified lines606162606364653 unmodified lines697071707273747576767778787980818210 unmodified lines93949595969798969798991001011021031041051061071081091101111121131001141151021161171181191201211081221231111121241251261271281291301311321331341351361371381391408 unmodified lines1491501511271521531541551 unmodified line{% if op == "max" or op == "min" %}{{ a }}[{{ idx }}] = {{ op }}({{ a }}[{{ idx }}], {{ a }}[{{ idx }} + {{ svar }}]);{% else %}{{ a }}[{{ idx }}] = {{ a }}[{{ idx }}] {{ "*" if op == "prod" else "+" }} {{ a }}[{{ idx }} + {{ svar }}];{% endif %}{% endmacro %}{% macro wgsl_tree_fold(arrays, op="add", idx="lid", wg="WORKGROUP_SIZE", svar="stride", typed=false, form="tail", breakInline=false, bodyInline=false, barrierFirst=false, reuse=false) %}{% macro wgsl_tree_fold(arrays, op="add", idx="lid", wg="WORKGROUP_SIZE", svar="stride", typed=false, form="tail", barrierFirst=false, reuse=false) %} var {{ svar }}{{ ": u32 " if typed else " " }}= {{ wg }} / 2u; loop { if ({{ svar }} == 0u) {15 unmodified lines{% endif %}{{ env.wgsl.resourceDeclarations }}
{% if not degenerateRow or writeResidualSum or (writeMean is defined and writeMean) %}const HIDDEN: u32 = {{ hiddenSize }}u;{% endif %}const WG: u32 = {{ workgroupSize }}u;{% if not degenerateRow %}
var<workgroup> pair_partial: array<vec2<f32>, WG>;
{% if useSubgroups %}fn reduce_pair(value: vec2<f32>, sg_lane: u32, sg_id: u32, num_sg: u32) -> vec2<f32> {fn reduce_pair(value: vec2<f32>, sg_id: u32, num_sg: u32, sg_size: u32) -> vec2<f32> { let s = vec2<f32>(subgroupAdd(value.x), subgroupAdd(value.y)); if (num_sg == 1u) { // Chrome on Qualcomm Adreno reports num_subgroups = 1 for a workgroup that spans several subgroups. // The reported subgroup count can be too low. Raise it to the fewest subgroups the workgroup can occupy, so an // under-reported count can neither take the one-subgroup return nor cut the fold short; a conformant count // always wins. let fold_count = max(num_sg, (WG + sg_size - 1u) >> firstTrailingBit(sg_size)); if (fold_count == 1u) { return s; } if (sg_lane == 0u) { if (subgroupElect()) { pair_partial[sg_id] = s; } workgroupBarrier(); var total = vec2<f32>(0.0, 0.0); for (var i = 0u; i < num_sg; i = i + 1u) { for (var i = 0u; i < fold_count; i = i + 1u) { total = total + pair_partial[i]; } return total;7 unmodified lines}{% endif %}{% endif %}{% if not degenerateRow or writeResidualSum or (writeMean is defined and writeMean) %}
fn residual_value(row: u32, d: u32) -> f32 { let index = row * HIDDEN + d;3 unmodified lines{% endif %} return value;}{% endif %}
@compute @workgroup_size(WG, 1, 1)fn main( @builtin({{ "global_invocation_id" if degenerateRow else "workgroup_id" }}) {{ "gid" if degenerateRow else "wg" }}: vec3<u32>{% if not degenerateRow %}, @builtin(local_invocation_id) lid: vec3<u32>{% endif %}{% if useSubgroups and not degenerateRow %}, @builtin(subgroup_invocation_id) sg_lane: u32, @builtin(subgroup_id) sg_id: u32, @builtin(num_subgroups) num_sg: u32{% endif %} @builtin(num_subgroups) num_sg: u32, @builtin(subgroup_size) sg_size: u32{% endif %}) { // Fold the row grid across workgroups; independent rows also include the // invocation offset. The bounds guard drops the final dispatch tail.10 unmodified lines{% endif %}{% if degenerateRow %}
// HIDDEN == 1: the row's mean is its only element, so the centered value and // the variance are exactly zero and the output reduces to beta. The closed // form avoids computing that zero by subtracting two equal rounded values. let row_inv = inverseSqrt(params.epsilon); // A one-element row has zero variance only when its rounded residual is // finite. Classify before using the closed form; invalid rows retain NaN. let residual = residual_value(row, 0u); let residual_bits = bitcast<u32>(residual); let residual_nonfinite = (residual_bits & 0x7f800000u) == 0x7f800000u; let epsilon_bits = bitcast<u32>(params.epsilon); let epsilon_zero = (epsilon_bits & 0x7fffffffu) == 0u; var row_inv = 0.0; if (residual_nonfinite) { row_inv = bitcast<f32>(residual_bits | 0x7fc00000u); } else if (epsilon_zero) { row_inv = bitcast<f32>((epsilon_bits & 0x7fffffffu) | 0x7f800000u); } else if (epsilon_bits == 0x7f800000u) { row_inv = 0.0; } else { row_inv = inverseSqrt(params.epsilon); }{% if packedStatistics is defined and packedStatistics %} row_stats[row] = vec2<f32>(residual_value(row, 0u), row_inv); row_stats[row] = vec2<f32>(residual, row_inv);{% elif writeMean is defined and writeMean %} mean[row] = residual_value(row, 0u); mean[row] = residual;{% endif %}{% if writeInvStd is defined and writeInvStd and not (packedStatistics is defined and packedStatistics) %} inv_std_var[row] = row_inv;{% endif %}{% if writeResidualSum %} let residual = residual_value(row, 0u); input_skip_bias_sum[row] = {{ scalar }}(residual);{% endif %} // 0.0 * row_inv keeps the IEEE result when epsilon == 0 makes row_inv +Inf. output[row] = {{ scalar }}(0.0 * row_inv * f32(gamma[0]){% if hasBeta %} + f32(beta[0]){% endif %});
let gamma_value = f32(gamma[0]); let gamma_nonfinite = (bitcast<u32>(gamma_value) & 0x7f800000u) == 0x7f800000u;{% if hasBeta %} let beta_value = f32(beta[0]); let beta_nan = (bitcast<u32>(beta_value) & 0x7fffffffu) > 0x7f800000u;{% endif %} if (residual_nonfinite || epsilon_zero || gamma_nonfinite{% if hasBeta %} || beta_nan{% endif %}) { output[row] = {{ scalar }}(bitcast<f32>(epsilon_bits | 0x7fc00000u)); return; } // Finite residual and scale: the output is 0 * inv * gamma, plus beta when // present, which keeps an infinite beta and the sign of a zero result. output[row] = {{ scalar }}(0.0 * row_inv * gamma_value{% if hasBeta %} + beta_value{% endif %});{% else %}
// Shifted moments: accumulating (x - x[0], (x - x[0])^2) keeps the sums8 unmodified lines }
{% if useSubgroups %} let totals = reduce_pair(acc, sg_lane, sg_id, num_sg); let totals = reduce_pair(acc, sg_id, num_sg, sg_size);{% else %} let totals = reduce_pair(acc, tid);{% endif %}11234566789101112131114151617{% macro flat_index_2d(workgroupSize, name="i", bound="params.count", guardInline=false) %}{% macro flat_index_2d(workgroupSize, name="i", bound="params.count") %}{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %} // 2D-folded flat index: gid.y carries the high bits past the dispatch's // per-axis workgroup fold width. let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }}; if ({{ name }} >= {{ bound }}) { return; }{% endmacro %} if ({{ name }} >= {{ bound }}) { return; }{% endmacro %}{{ env.wgsl.resourceDeclarations }}// Separate optional outputs keep the reduction within eight storage bindings.@compute @workgroup_size({{ workgroupSize }})fn main(@builtin(global_invocation_id) gid: vec3<u32>) {{{ flat_index_2d(workgroupSize, "row", "params.rows", guardInline=true) }}{{ flat_index_2d(workgroupSize, "row", "params.rows") }} let stats = row_stats[row]; mean[row] = stats.x; inv_std_var[row] = stats.y;12345456789137 unmodified lines147148149149150150151152153154155156157158159160161162163164165166167168169170156157171172173174175176177178179180181182183184185186187188189190191192193194195163196197198199167168200201202203204205206207208209210211212213214215216217218219173220221222223224225226227228229230231232233234235178236237238239182183240241242243244245246247248249250251252253254255256257186258259260261262263264265266267268269270271272100 unmodified lines37337437529329429529637637737837924 unmodified lines40440540632740740840941087 unmodified lines49849950042150150250350420 unmodified lines525526527448528529530531143 unmodified lines67567667759859960067867968068135 unmodified lines71771871964272072172272353 unmodified lines77777877970270370478078178278360 unmodified lines844845846771847848849850159 unmodified lines101010111012937938939101310141015101625 unmodified lines104210431044971104510461047104858 unmodified lines11071108110910361110111111121113109 unmodified lines122312241225115211531154122612271228122918 unmodified lines124812491250117912511252125312546 unmodified lines126112621263119212641265126612677 unmodified lines127512761277120612781279128012818 unmodified lines129012911292122112931294129512969 unmodified lines130613071308123713091310131113129 unmodified lines132213231324125313251326132713289 unmodified lines133813391340126913411342134313449 unmodified lines1354135513561285135713581359136012 unmodified lines137313741375130413761377137813798 unmodified lines138813891390131913911392139313946 unmodified lines140114021403133214041405140614077 unmodified lines141514161417134614181419142014218 unmodified lines143014311432136114331434143514369 unmodified lines144614471448137714491450145114529 unmodified lines146214631464139314651466146714689 unmodified lines147814791480140914811482148314849 unmodified lines149414951496142514971498149915009 unmodified lines151015111512144115131514151515168 unmodified lines15251526152714561528152915301531{ "fixtureArrays": { "ort_batch2_bias_flattened_tokens_input_skipT": [0.1, -0.2, 0.3, 1, 0.5, 0.1, 0.4, 1.6, 1.8, -0.3, 0, 1, -0.5, 0.4, 0.8, -0.6], "ort_batch2_flattened_tokens_input_inputT": [0.8, -0.5, 0, 1, 0.5, 0.2, 0.3, -0.6, 0.8, -0.5, 0, 1, 0.5, 0.2, 0.3, -0.6], "ort_batch2_skip_broadcast_no_batch_size_output_outputT": [0.2843385934829712, -0.17090578377246857, -0.9289716482162476, 4.692415237426758, 0.4611165225505829, -0.21333980560302734, -0.29631003737449646, 3.5148544311523438, 0.2843385934829712, -0.17090578377246857, -0.9289716482162476, 4.692415237426758, 0.4611165225505829, -0.21333980560302734, -0.29631003737449646, 3.5148544311523438] "ort_batch2_skip_broadcast_no_batch_size_output_outputT": [0.2843385934829712, -0.17090578377246857, -0.9289716482162476, 4.692415237426758, 0.4611165225505829, -0.21333980560302734, -0.29631003737449646, 3.5148544311523438, 0.2843385934829712, -0.17090578377246857, -0.9289716482162476, 4.692415237426758, 0.4611165225505829, -0.21333980560302734, -0.29631003737449646, 3.5148544311523438], "hidden_size_one_bias_output_only_input_inputT": [2, "Infinity", "-Infinity", "NaN", 1, 1, 1, 3.4028234663852886e+38, 2, -4, 0.5, 1.25, -2, 4, -0.5, 0, 3], "hidden_size_one_bias_output_only_input_skipT": [3, 0, 0, 0, "Infinity", "-Infinity", "NaN", 3.4028234663852886e+38, 3, 1, -0.5, 0.5, 1, -2, 2, 0, -1] }, "cases": [ {137 unmodified lines "name": "hidden_size_one_bias_path", "attrs": { "epsilon": 0.00001 }, "inputs": { "inputT": { "dtype": "float32", "shape": [3, 1], "data": { "kind": "values", "values": [2.0, -4.0, 0.5] } }, "skipT": { "dtype": "float32", "shape": [3, 1], "data": { "kind": "values", "values": [3.0, 1.0, -0.5] } }, "inputT": { "dtype": "float32", "shape": [10, 1], "data": { "kind": "values", "values": [2.0, -4.0, 0.5, "Infinity", "-Infinity", "NaN", 1.0, 1.0, 1.0, 3.4028234663852886e+38] } }, "skipT": { "dtype": "float32", "shape": [10, 1], "data": { "kind": "values", "values": [3.0, 1.0, -0.5, 0.0, 0.0, 0.0, "Infinity", "-Infinity", "NaN", 3.4028234663852886e+38] } }, "gammaT": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [7.0] } }, "betaT": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-2.0] } }, "biasT": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.25] } } }, "outputs": { "outputT": { "dtype": "float32", "shape": [3, 1], "tolerance": 0.000001 }, "residualT": { "dtype": "float32", "shape": [3, 1], "tolerance": 0.000001 } "outputT": { "dtype": "float32", "shape": [10, 1], "tolerance": 0.000001, "data": { "kind": "values", "values": [-2.0, -2.0, -2.0, "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN"] }, "allowNaN": true }, "residualT": { "dtype": "float32", "shape": [10, 1], "tolerance": 0.000001, "data": { "kind": "values", "values": [5.25, -2.75, 0.25, "Infinity", "-Infinity", "NaN", "Infinity", "-Infinity", "NaN", "Infinity"] }, "allowNaN": true } }, "provenance": { "notes": "Hidden size one with bias 0.25, gamma 7 and beta -2 over ten rows: three finite rows, rows with +-Infinity or NaN in the input or skip, and finite inputs whose sum overflows to +Infinity. The residual output holds each sum; the normalized output is beta (-2) for a finite residual and NaN otherwise." } }, { "name": "hidden_size_one_bias_output_only", "provenance": { "notes": "Pins the scalar hidden-size-one closed form when the optional residual sum is not requested." "notes": "Hidden size one over 4,097 rows with bias 0.25, gamma 7 and beta -2: a 17-row cycle mixes finite rows with rows whose input or skip is +-Infinity or NaN and a row of finite inputs whose sum overflows. Each finite residual normalizes to zero, giving beta (-2), and each non-finite residual gives NaN." }, "attrs": { "epsilon": 0.00001 }, "inputs": { "inputT": { "dtype": "float32", "shape": [1, 1], "data": { "kind": "values", "values": [2.0] } }, "skipT": { "dtype": "float32", "shape": [1, 1], "data": { "kind": "values", "values": [3.0] } }, "inputT": { "dtype": "float32", "shape": [4097, 1], "data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/hidden_size_one_bias_output_only_input_inputT" } } }, "skipT": { "dtype": "float32", "shape": [4097, 1], "data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/hidden_size_one_bias_output_only_input_skipT" } } }, "gammaT": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [7.0] } }, "betaT": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-2.0] } }, "biasT": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.25] } } }, "outputs": { "outputT": { "dtype": "float32", "shape": [1, 1], "tolerance": 0.000001 } } "outputs": { "outputT": { "dtype": "float32", "shape": [4097, 1], "tolerance": 0.000001, "data": { "kind": "cycle", "values": [-2.0, "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0] }, "allowNaN": true } } }, { "name": "hidden_size_one_no_beta_output_only", "provenance": { "notes": "Pins the supported no-beta hidden-size-one closed form: every centered value is zero, so the output is zero." "notes": "Hidden size one over 4,097 rows with gamma 7 and no bias or beta: a 17-row cycle mixes finite rows with rows whose input or skip is +-Infinity or NaN and a row of finite inputs whose sum overflows. Each finite residual normalizes to zero, giving 0, and each non-finite residual gives NaN." }, "attrs": { "epsilon": 0.00001 }, "inputs": { "inputT": { "dtype": "float32", "shape": [1, 1], "data": { "kind": "values", "values": [2.0] } }, "skipT": { "dtype": "float32", "shape": [1, 1], "data": { "kind": "values", "values": [3.0] } }, "inputT": { "dtype": "float32", "shape": [4097, 1], "data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/hidden_size_one_bias_output_only_input_inputT" } } }, "skipT": { "dtype": "float32", "shape": [4097, 1], "data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/hidden_size_one_bias_output_only_input_skipT" } } }, "gammaT": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [7.0] } } }, "outputs": { "outputT": { "dtype": "float32", "shape": [1, 1], "tolerance": 0.000001 } } "outputs": { "outputT": { "dtype": "float32", "shape": [4097, 1], "tolerance": 0.000001, "data": { "kind": "cycle", "values": [0.0, "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] }, "allowNaN": true } } }, { "name": "hidden_size_one_bias_rows65535_dispatch_edge",100 unmodified lines "inputT": { "dtype": "float32", "shape": [4, 4], "data": { "kind": "values", "values": [0.7, -0.4, -0.2, 1.2, 0.4, 0.3, 0.1, -0.4, 0.7, -0.4, -0.2, 1.2, 0.4, 0.3, 0.1, -0.4] } "data": { "kind": "cycle", "values": [0.7, -0.4, -0.2, 1.2, 0.4, 0.3, 0.1, -0.4] } }, "skipT": { "dtype": "float32",24 unmodified lines "inputT": { "dtype": "float32", "shape": [4, 4], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_batch2_flattened_tokens_input_inputT" } } "data": { "kind": "cycle", "values": [0.8, -0.5, 0.0, 1.0, 0.5, 0.2, 0.3, -0.6] } }, "skipT": { "dtype": "float32",87 unmodified lines "inputT": { "dtype": "float32", "shape": [2, 2, 4], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_batch2_flattened_tokens_input_inputT" } } "data": { "kind": "cycle", "values": [0.8, -0.5, 0.0, 1.0, 0.5, 0.2, 0.3, -0.6] } }, "skipT": { "dtype": "float32",20 unmodified lines "provenance": { "source": "onnxruntime/test/contrib_ops/skiplayernorm_op_test.cc", "test": "SkipLayerNormTest.SkipLayerNormBatch1_NoBeta", "notes": "ORT shape [1, 2, 4] is represented as [2, 4] tokens by this lowered fixture, with beta omitted." "notes": "Two tokens of width 4, with a scale and a skip input but no beta." }, "attrs": { "epsilon": 1e-12 }, "inputs": {143 unmodified lines }, { "name": "beta_bias_output_only_hidden6_unaligned_row", "provenance": { "notes": "Row-kernel arm of beta_bias_output_only: hidden=6 fails vec4Aligned. 6 storage buffers." }, "provenance": { "notes": "Hidden size 6 is not a multiple of 4, with beta and bias present." }, "attrs": { "epsilon": 0.00001 }, "inputs": { "inputT": {35 unmodified lines "inputT": { "dtype": "float32", "shape": [2, 2, 4], "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_batch2_flattened_tokens_input_inputT" } } "data": { "kind": "cycle", "values": [0.8, -0.5, 0.0, 1.0, 0.5, 0.2, 0.3, -0.6] } }, "skipT": { "dtype": "float32",53 unmodified lines }, { "name": "f32_hidden768_no_bias_residual", "provenance": { "notes": "A compact hidden-size-768 residual normalization exercises the subgroup route and its reduced-tier fallback without bias." }, "provenance": { "notes": "A hidden size of 768 (4 rows, float32) with beta, no bias and the residual output." }, "attrs": { "epsilon": 0.00001 }, "inputs": { "inputT": {60 unmodified lines { "name": "f32_hidden1025_bias_residual", "provenance": { "notes": "A compact hidden-size-1025 normalization exercises the unaligned two-pass path with bias and residual output." "notes": "A hidden size of 1025 (3 rows, float32) with beta, bias and the residual output; 1025 leaves a remainder of 1 after multiples of 4." }, "attrs": { "epsilon": 0.00001 }, "inputs": {159 unmodified lines }, { "name": "rank3_no_bias_residual", "provenance": { "notes": "Rank-3 activation shape carrying the residual output, the form ONNX Runtime's transformer fusion emits when the pre-normalization sum feeds the next block." }, "provenance": { "notes": "Rank-3 activation [1, 4, 768] with the residual (sum) output present and no bias." }, "attrs": { "epsilon": 0.00001 }, "inputs": { "inputT": {25 unmodified lines { "name": "rank3_beta_no_bias_output_only_hidden6_unaligned_row", "provenance": { "notes": "Rank-3 at a hidden size that is not a multiple of four, so the scalar row route serves it." "notes": "Rank-3 activation [1, 2, 6] whose hidden size of 6 is not a multiple of 4, with beta and no bias." }, "attrs": { "epsilon": 0.00001 }, "inputs": {58 unmodified lines }, { "name": "f16_beta_bias_output_only_hidden6_unaligned_row", "provenance": { "notes": "Half precision at an unaligned hidden size, which the scalar row route serves." }, "provenance": { "notes": "Float16 with hidden size 6 (not a multiple of 4), beta and bias." }, "requires": { "features": ["shader-f16"] }, "attrs": { "epsilon": 0.00001 }, "inputs": {109 unmodified lines }, { "name": "f16_no_beta_output_only", "provenance": { "notes": "Half precision with neither beta nor bias at an aligned hidden size, which is the vec4 arm of that pair." }, "provenance": { "notes": "Float16 with neither beta nor bias at a hidden size of 8 (a multiple of 4)." }, "requires": { "features": ["shader-f16"] }, "attrs": { "epsilon": 0.00001 }, "inputs": {18 unmodified lines { "name": "independent_rows_float32_257x1_option0_wgdefault_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values." }, "attrs": { "epsilon": 0.00001 }, "inputs": {6 unmodified lines { "name": "independent_rows_float32_257x1_option1_wgdefault_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values." }, "attrs": { "epsilon": 0.00001 }, "inputs": {7 unmodified lines { "name": "independent_rows_float32_257x1_option2_wgdefault_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values." }, "attrs": { "epsilon": 0.00001 }, "inputs": {8 unmodified lines { "name": "independent_rows_float32_3x31x1_option2_wg1_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 1." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 1 },9 unmodified lines { "name": "independent_rows_float32_3x31x1_option2_wg8_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 8." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 8 },9 unmodified lines { "name": "independent_rows_float32_3x31x1_option2_wg64_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 64." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 64 },9 unmodified lines { "name": "independent_rows_float32_3x31x1_option2_wg128_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 128." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 128 },9 unmodified lines { "name": "independent_rows_float32_524289x1_option3_wg8_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "524,289 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values and a residual sum. Its tunable sets a maximum workgroup size of 8." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 8 },12 unmodified lines { "name": "independent_rows_float32_257x1_option2_wgdefault_epsilon0", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 0: with a single element the variance is zero, so the normalization divides zero by zero and NaN outputs are allowed." }, "attrs": { "epsilon": 0 }, "inputs": {8 unmodified lines { "name": "independent_rows_float16_257x1_option0_wgdefault_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values." }, "attrs": { "epsilon": 0.00001 }, "inputs": {6 unmodified lines { "name": "independent_rows_float16_257x1_option1_wgdefault_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values." }, "attrs": { "epsilon": 0.00001 }, "inputs": {7 unmodified lines { "name": "independent_rows_float16_257x1_option2_wgdefault_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values." }, "attrs": { "epsilon": 0.00001 }, "inputs": {8 unmodified lines { "name": "independent_rows_float16_3x31x1_option2_wg1_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 1." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 1 },9 unmodified lines { "name": "independent_rows_float16_3x31x1_option2_wg8_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 8." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 8 },9 unmodified lines { "name": "independent_rows_float16_3x31x1_option2_wg64_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 64." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 64 },9 unmodified lines { "name": "independent_rows_float16_3x31x1_option2_wg128_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "93 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 128." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 128 },9 unmodified lines { "name": "independent_rows_float16_524289x1_option2_wg8_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "524,289 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values. Its tunable sets a maximum workgroup size of 8." }, "attrs": { "epsilon": 0.00001 }, "tunables": { "MAX_WORKGROUP_SIZE": 8 },9 unmodified lines { "name": "independent_rows_float16_257x1_option2_wgdefault_epsilon0", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float16 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 0: with a single element the variance is zero, so the normalization divides zero by zero and NaN outputs are allowed." }, "attrs": { "epsilon": 0 }, "inputs": {8 unmodified lines { "name": "independent_rows_float32_257x1_option3_wgdefault_epsilon0.00001", "provenance": { "notes": "One-element normalization has an intrinsically uniform result. Uniform inputs pin its closed-form value, workgroup tails, optional outputs, and epsilon behavior; the GPU row-coverage test checks poisoned outputs and varying residuals separately." "notes": "257 float32 rows of hidden size 1 (input 1.25, skip 0.5, constant) with gamma and beta and bias and epsilon 1e-05: each row normalizes a single element, so the result is uniform and has a closed form. The outputs are the normalized values and a residual sum." }, "attrs": { "epsilon": 0.00001 }, "inputs": {README.md+18-42
build/webgpu/bench.json-17
build/webgpu/manifest.json+1-1553
build/webgpu/metadata.json+1-70
build/webgpu/norm-skip-row-vec4.wgsl.jinja+18-11
build/webgpu/norm-skip-row.wgsl.jinja+46-21
build/webgpu/norm-stats-copy.wgsl.jinja+6-3
build/webgpu/test.json+128-56