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/timestep_embedding.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 / timestep_embedding.comp` 42 lines ยท 1028 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 nb1; 8 uint dim; 9 uint max_period; 10 } p; 11 12 #include "types.glsl" 13 14 #extension GL_EXT_control_flow_attributes : enable 15 #define BLOCK_SIZE 256 16 17 layout(local_size_x = BLOCK_SIZE, local_size_y = 1, local_size_z = 1) in; 18 19 layout (binding = 0) readonly buffer X {A_TYPE data_a[];}; 20 layout (binding = 1) writeonly buffer D {D_TYPE data_d[];}; 21 22 void main() { 23 const uint i = gl_WorkGroupID.y; 24 const uint j = gl_GlobalInvocationID.x; 25 const uint d_offset = i * p.nb1; 26 27 const uint half_dim = p.dim / 2; 28 29 if (p.dim % 2 != 0 && j == half_dim) { 30 data_d[d_offset + 2 * half_dim] = 0.f; 31 } 32 33 if (j >= half_dim) { 34 return; 35 } 36 37 const float timestep = float(data_a[i]); 38 const float freq = float(exp(-log(p.max_period) * j / half_dim)); 39 const float arg = timestep * freq; 40 data_d[d_offset + j] = D_TYPE(cos(arg)); 41 data_d[d_offset + j + half_dim] = D_TYPE(sin(arg)); 42 }