Spaces:
Running
Running
Download kernels/embed.wgsl from EncryptidSystems/EdgeAI: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/spaces/EncryptidSystems/EdgeAI/resolve/main/kernels/embed.wgsl
- Command line
-
hf download hf://spaces/EncryptidSystems/EdgeAI/kernels/embed.wgsl
-
curl -L -o embed.wgsl https://huggingface.co/spaces/EncryptidSystems/EdgeAI/resolve/main/kernels/embed.wgsl
855 Bytes
| // The token's embedding row (bf16) into the residual stream x (f32). The | |
| // embedding may be split across buffers; this binding is the chunk holding | |
| // the token, and st.row is the token's row within it. | |
| override D: u32; | |
| override SCALE: f32 = 1.0; // Gemma multiplies the token by sqrt(hidden). 1 for every other model. | |
| struct Step { | |
| pos: u32, | |
| row: u32, | |
| p0: u32, | |
| p1: u32, | |
| } | |
| var<uniform> st: Step; | |
| var<storage, read> emb: array<u32>; // rows x D bf16, two per word | |
| var<storage, read_write> x: array<f32>; | |
| fn main( gid: vec3u) { | |
| let i = gid.x; | |
| if (i >= D) { | |
| return; | |
| } | |
| let e = st.row * D + i; | |
| let w = emb[e >> 1u]; | |
| x[i] = bitcast<f32>(select(w << 16u, w & 0xffff0000u, (e & 1u) == 1u)) * SCALE; | |
| } | |