ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / src / ggml-vulkan / vulkan-shaders / generic_binary_head.glsl
| 1 | #extension GL_EXT_shader_16bit_storage : require |
| 2 | #extension GL_EXT_control_flow_attributes : require |
| 3 | |
| 4 | #include "utils.glsl" |
| 5 | #if RMS_NORM_ROPE_FUSION |
| 6 | #include "rope_params.glsl" |
| 7 | #endif |
| 8 | |
| 9 | layout (push_constant) uniform parameter |
| 10 | { |
| 11 | uint ne; |
| 12 | uint ne00; uint ne01; uint ne02; uint ne03; uint nb00; uint nb01; uint nb02; uint nb03; |
| 13 | uint ne10; uint ne11; uint ne12; uint ne13; uint nb10; uint nb11; uint nb12; uint nb13; |
| 14 | uint ne20; uint ne21; uint ne22; uint ne23; uint nb20; uint nb21; uint nb22; uint nb23; |
| 15 | uint misalign_offsets; |
| 16 | float param1; float param2; int param3; |
| 17 | #if RMS_NORM_ROPE_FUSION |
| 18 | rope_params rope; |
| 19 | #endif |
| 20 | } p; |
| 21 | |
| 22 | #if !RMS_NORM_ROPE_FUSION |
| 23 | layout (binding = 0) readonly buffer A {A_TYPE data_a[];}; |
| 24 | #if defined(A_TYPE_PACKED16) |
| 25 | layout (binding = 0) readonly buffer A_PACKED16 {A_TYPE_PACKED16 data_a_packed16[];}; |
| 26 | #endif |
| 27 | #if defined(A_TYPE_PACKED32) |
| 28 | layout (binding = 0) readonly buffer A_PACKED32 {A_TYPE_PACKED32 data_a_packed32[];}; |
| 29 | #endif |
| 30 | |
| 31 | layout (binding = 1) readonly buffer B {B_TYPE data_b[];}; |
| 32 | layout (binding = 2) writeonly buffer D {D_TYPE data_d[];}; |
| 33 | #endif |
| 34 | |
| 35 | // true if src0/src1 are the same shape and the indices can be reused without additional modulus |
| 36 | layout(constant_id = 0) const bool norepeat = false; |
| 37 | |
| 38 | uint get_idx() { |
| 39 | return gl_GlobalInvocationID.z * 262144 + gl_GlobalInvocationID.y * 512 + gl_GlobalInvocationID.x; |
| 40 | } |
| 41 | |
| 42 | uint get_aoffset() { return p.misalign_offsets >> 16; } |
| 43 | uint get_boffset() { return (p.misalign_offsets >> 8) & 0xFF; } |
| 44 | uint get_doffset() { return p.misalign_offsets & 0xFF; } |
| 45 | |
| 46 | |
| 47 | void get_indices(uint idx, out uint i00, out uint i01, out uint i02, out uint i03) { |
| 48 | get_indices(idx, i00, i01, i02, i03, p.ne00, p.ne01, p.ne02, p.ne03); |
| 49 | } |
| 50 | |
| 51 | uint src0_idx(uint i00, uint i01, uint i02, uint i03) { |
| 52 | return i03*p.nb03 + i02*p.nb02 + i01*p.nb01 + i00*p.nb00; |
| 53 | } |
| 54 | |
| 55 | uint src1_idx(uint i00, uint i01, uint i02, uint i03) { |
| 56 | if (norepeat) { |
| 57 | return i03*p.nb13 + i02*p.nb12 + i01*p.nb11 + i00*p.nb10; |
| 58 | } else { |
| 59 | return fastmod(i03, p.ne13)*p.nb13 + fastmod(i02, p.ne12)*p.nb12 + fastmod(i01, p.ne11)*p.nb11 + fastmod(i00, p.ne10)*p.nb10; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | uint dst_idx(uint i00, uint i01, uint i02, uint i03) { |
| 64 | return i03*p.nb23 + i02*p.nb22 + i01*p.nb21 + i00*p.nb20; |
| 65 | } |