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/ssm_conv.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 / ssm_conv.comp` 60 lines ยท 1790 bytes Raw Blame History 1 #version 450 2 3 #extension GL_EXT_control_flow_attributes : require 4 5 #include "types.glsl" 6 7 layout(constant_id = 0) const uint BLOCK_SIZE = 32; 8 layout(constant_id = 1) const uint TOKENS_PER_WG = 16; 9 layout(constant_id = 2) const bool APPLY_BIAS = false; 10 layout(constant_id = 3) const bool APPLY_SILU = false; 11 12 layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z = 1) in; 13 14 layout(binding = 0) readonly buffer Src0 { float src0[]; }; 15 layout(binding = 1) readonly buffer Src1 { float src1[]; }; 16 layout(binding = 2) readonly buffer Bias { float bias[]; }; 17 layout(binding = 3) buffer Dst { float dst[]; }; 18 19 layout(push_constant) uniform PushConstants { 20 uint nb01; uint nb02; 21 uint nb11; 22 uint dst_nb0; uint dst_nb1; uint dst_nb2; 23 uint nc; uint ncs; uint nr; uint n_t; uint n_s; 24 }; 25 26 void main() { 27 const uint i1 = gl_GlobalInvocationID.x; 28 const uint i2 = gl_WorkGroupID.y * TOKENS_PER_WG + gl_LocalInvocationID.y; 29 const uint i3 = gl_WorkGroupID.z; 30 31 if (i1 >= nr || i2 >= n_t || i3 >= n_s) { 32 return; 33 } 34 35 const uint src0_base = i3 * (nb02 / 4) + i2 + i1 * (nb01 / 4); 36 const uint src1_base = i1 * (nb11 / 4); 37 38 float sum = 0.0; 39 40 if (nc == 4) { 41 sum = dot( 42 vec4(src0[src0_base], src0[src0_base + 1], src0[src0_base + 2], src0[src0_base + 3]), 43 vec4(src1[src1_base], src1[src1_base + 1], src1[src1_base + 2], src1[src1_base + 3]) 44 ); 45 } else { 46 [[unroll]] for (uint i0 = 0; i0 < nc; i0++) { 47 sum += src0[src0_base + i0] * src1[src1_base + i0]; 48 } 49 } 50 51 if (APPLY_BIAS) { 52 sum += bias[i1]; 53 } 54 if (APPLY_SILU) { 55 sum = sum / (1.0f + exp(-sum)); 56 } 57 58 const uint dst_idx = i3 * (dst_nb2 / 4) + i2 * (dst_nb1 / 4) + i1; 59 dst[dst_idx] = sum; 60 }