Spaces:
Running
Running
Download kernels/wedge.wgsl from EncryptidSystems/EdgeAI: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/EncryptidSystems/EdgeAI/resolve/main/kernels/wedge.wgsl
- Command line
-
hf download hf://spaces/EncryptidSystems/EdgeAI/kernels/wedge.wgsl
-
curl -L -o wedge.wgsl https://huggingface.co/spaces/EncryptidSystems/EdgeAI/resolve/main/kernels/wedge.wgsl
1.1 kB
| // One residual face. The wedge is the sum over cells of (sum of the carry) times (sum of the write). | |
| // flag[0] is 1 when that area is positive. The write is added either way: dropping it when the | |
| // cell sums cancel removes the attention or the feed-forward and the reply comes apart. | |
| // One thread, so the sum is the same order as the reference forward. | |
| // No paper equation. | |
| override DIM: u32; | |
| override NCELL: u32; | |
| override M: u32; | |
| var<storage, read_write> x: array<f32>; | |
| var<storage, read> w: array<f32>; | |
| var<storage, read> order: array<u32>; | |
| var<storage, read_write> flag: array<u32>; | |
| fn main() { | |
| var area = 0.0; | |
| for (var c = 0u; c < NCELL; c++) { | |
| var cs = 0.0; | |
| var ws = 0.0; | |
| let base = c * M; | |
| for (var t = 0u; t < M; t++) { | |
| let j = order[base + t]; | |
| cs += x[j]; | |
| ws += w[j]; | |
| } | |
| area += cs * ws; | |
| } | |
| if (area > 0.0) { | |
| flag[0] = 1u; | |
| } else { | |
| flag[0] = 0u; | |
| } | |
| for (var i = 0u; i < DIM; i++) { | |
| x[i] += w[i]; | |
| } | |
| } | |