sync c928d21e6cc1
Browse filesFiles changed (3)
12344 unmodified lines48495051525354555657585960616263{% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}{% if note == "dispatch-limit" %}// 2D-folded flat index: gid.y carries the high bits past the44 unmodified lines// make this op more accurate than the graph it replaces.const HIDDEN: u32 = {{ hidden }}u;@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {{{ flat_index_2d() }}{% if vec4 %}// A vec4 group is four consecutive channels of one row: HIDDEN % 4 == 0 stops// it from ever straddling two rows, so the whole group shares one gate value.let g = vec4<{{ scalar }}>(gate[i * 4u / HIDDEN]);output[i] = x[i] + fma(y[i], g, vec4<{{ scalar }}>(0.0));{% else %}let g = gate[i / HIDDEN];output[i] = x[i] + fma(y[i], g, {{ scalar }}(0.0));{% endif %}}1234567891011121314151617181920212223242526272844 unmodified lines73747576777879808182838485868788899091{% macro flat_tail_open() %}@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {// 2D-folded flat index: gid.y carries the high bits when the element count exceeds the// maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills the rest into y).let invocation = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;{% if source.itemsPerInvocation is defined %}// Tail-safe scalar x4 keeps vector-like dispatch density without requiring// the logical tensor length (or its storage binding) to be vec4 aligned.let begin = invocation * {{ source.itemsPerInvocation }}u;let end = min(begin + {{ source.itemsPerInvocation }}u, params.count);for (var i = begin; i < end; i = i + 1u) {{%- else %}let i = invocation;if (i >= params.count) {return;}{%- endif %}{% endmacro %}{% macro flat_tail_close() %}{% if source.itemsPerInvocation is defined %}}{% endif %}{% endmacro %}{% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}{% if note == "dispatch-limit" %}// 2D-folded flat index: gid.y carries the high bits past the44 unmodified lines// make this op more accurate than the graph it replaces.const HIDDEN: u32 = {{ hidden }}u;{% if vec4 %}@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {{{ flat_index_2d() }}// A vec4 group is four consecutive channels of one row: HIDDEN % 4 == 0 stops// it from ever straddling two rows, so the whole group shares one gate value.let g = vec4<{{ scalar }}>(gate[i * 4u / HIDDEN]);output[i] = x[i] + fma(y[i], g, vec4<{{ scalar }}>(0.0));}{% else %}{{ flat_tail_open() }}let g = gate[i / HIDDEN];output[i] = x[i] + fma(y[i], g, {{ scalar }}(0.0));{{ flat_tail_close() -}}}{% endif %}
102 unmodified lines10310410510610710830 unmodified lines139140141142143144145102 unmodified lines"id": "main","name": "GatedAdd.scalar","shader": "gated-add.wgsl.jinja","bindings": [{"name": "x",30 unmodified lines"struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.X)" }] }}],"dispatch": { "threads": "numel(shapes.X)", "workgroupSize": "tunables.WORKGROUP_SIZE" }}]}102 unmodified lines10310410510610710810930 unmodified lines140141142143144145146102 unmodified lines"id": "main","name": "GatedAdd.scalar","shader": "gated-add.wgsl.jinja","source": { "inputs": { "itemsPerInvocation": 4 } },"bindings": [{"name": "x",30 unmodified lines"struct": { "name": "Params", "fields": [{ "name": "count", "type": "u32", "value": "numel(shapes.X)" }] }}],"dispatch": { "threads": "ceilDiv(numel(shapes.X), 4)", "workgroupSize": "tunables.WORKGROUP_SIZE" }}]}
1234561 unmodified line89101112131415161718{"name": "com.microsoft.GatedAdd","id": "_com_microsoft_gatedadd_webgpu_c9e5b9d","version": 1,"license": "Apache-2.0","backend": { "type": "webgpu" },1 unmodified line"algorithm": "sha256","files": {"bench.json": "Yo5szY3Ccb8NOxk0YLKXGApxHMFCENocZt9z2/GaJew=","gated-add.wgsl.jinja": "GiWIIFkb2GXB3/MDWr4Buyc/kKQrH5xr2tcee1RCOog=","manifest.json": "eGSFQTnmYL4/Zqwfz8zkKFJgFT1Fn5IjP+slAJPCuTU=","test.json": "5Gsy9SVd5u5t8bVgKOLTcNMfO4wqI7rFSjHIhPpLEgk="}},"provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } },"webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/com.microsoft.GatedAdd" }}1234561 unmodified line89101112131415161718{"name": "com.microsoft.GatedAdd","id": "_com_microsoft_gatedadd_webgpu_bd62a87","version": 1,"license": "Apache-2.0","backend": { "type": "webgpu" },1 unmodified line"algorithm": "sha256","files": {"bench.json": "Yo5szY3Ccb8NOxk0YLKXGApxHMFCENocZt9z2/GaJew=","gated-add.wgsl.jinja": "1jbbfo5jhq8VJQHFSPM20gaFGAman4LWBgrssi9fQ5E=","manifest.json": "t9s9nEQJMkL8JEPMCsIRRZhZlohyMFsAkyIW7GIwTRw=","test.json": "5Gsy9SVd5u5t8bVgKOLTcNMfO4wqI7rFSjHIhPpLEgk="}},"provenance": { "kernel": { "sha": "c928d21e6cc1310861cba3bafb75f5f679ecf5f3", "dirty": false } },"webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/com.microsoft.GatedAdd" }}
build/webgpu/gated-add.wgsl.jinja+30-2
build/webgpu/manifest.json+2-1
build/webgpu/metadata.json+4-4