Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-vulkan/vulkan-shaders/out_prod.comp # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-vulkan / vulkan-shaders / out_prod.comp` 59 lines ยท 1863 bytes Raw Blame History 1 #version 450 2 3 #extension GL_EXT_shader_16bit_storage : require 4 5 layout (push_constant) uniform parameter 6 { 7 uint ne; 8 uint ne00; uint ne01; uint ne02; uint ne03; uint nb00; uint nb01; uint nb02; uint nb03; 9 uint ne10; uint ne11; uint ne12; uint ne13; uint nb10; uint nb11; uint nb12; uint nb13; 10 uint ne20; uint ne21; uint ne22; uint ne23; uint nb20; uint nb21; uint nb22; uint nb23; 11 uint misalign_offsets; 12 float param1; float param2; int param3; 13 } p; 14 15 layout (binding = 0) readonly buffer A {float data_a[];}; 16 layout (binding = 1) readonly buffer B {float data_b[];}; 17 layout (binding = 2) writeonly buffer D {float data_d[];}; 18 19 uint get_idx() { 20 return gl_GlobalInvocationID.z * 262144 + gl_GlobalInvocationID.y * 512 + gl_GlobalInvocationID.x; 21 } 22 23 uint get_aoffset() { return p.misalign_offsets >> 16; } 24 uint get_boffset() { return (p.misalign_offsets >> 8) & 0xFF; } 25 uint get_doffset() { return p.misalign_offsets & 0xFF; } 26 27 layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 28 29 void main() { 30 uint idx = get_idx(); 31 if (idx >= p.ne) { 32 return; 33 } 34 35 uint tmp = idx; 36 uint i0 = tmp % p.ne20; tmp /= p.ne20; 37 uint i1 = tmp % p.ne21; tmp /= p.ne21; 38 uint i2 = tmp % p.ne22; tmp /= p.ne22; 39 uint i3 = tmp; 40 41 uint a_i0 = i0 % p.ne00; 42 uint a_i2 = i2 / (p.ne22 / p.ne02); 43 uint a_i3 = i3 / (p.ne23 / p.ne03); 44 45 uint b_i0 = i1 % p.ne10; 46 uint b_i2 = i2; 47 uint b_i3 = i3; 48 49 float sum = 0.0f; 50 uint K = p.ne01; 51 for (uint k = 0; k < K; k++) { 52 uint aoff = get_aoffset() + a_i3*p.nb03 + a_i2*p.nb02 + k*p.nb01 + a_i0*p.nb00; 53 uint boff = get_boffset() + b_i3*p.nb13 + b_i2*p.nb12 + k*p.nb11 + b_i0*p.nb10; 54 sum += data_a[aoff] * data_b[boff]; 55 } 56 57 uint doff = get_doffset() + i3*p.nb23 + i2*p.nb22 + i1*p.nb21 + i0*p.nb20; 58 data_d[doff] = sum; 59 }