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 / add_id.comp
| 1 | #version 450 |
| 2 | |
| 3 | #extension GL_EXT_control_flow_attributes : require |
| 4 | |
| 5 | #include "types.glsl" |
| 6 | |
| 7 | layout (push_constant) uniform parameter |
| 8 | { |
| 9 | uint ne0; |
| 10 | uint ne1; |
| 11 | uint s01; |
| 12 | uint s02; |
| 13 | uint s11; |
| 14 | uint s21; |
| 15 | } p; |
| 16 | |
| 17 | #define BLOCK_SIZE 512 |
| 18 | |
| 19 | layout(local_size_x = BLOCK_SIZE, local_size_y = 1, local_size_z = 1) in; |
| 20 | |
| 21 | layout (binding = 0) readonly buffer X {A_TYPE data_a[];}; |
| 22 | layout (binding = 1) readonly buffer Y {B_TYPE data_b[];}; |
| 23 | layout (binding = 2) readonly buffer Z {int32_t data_c[];}; |
| 24 | layout (binding = 3) writeonly buffer D {D_TYPE data_d[];}; |
| 25 | |
| 26 | void main() { |
| 27 | const uint i1 = gl_WorkGroupID.x; |
| 28 | const uint i2 = gl_WorkGroupID.y; |
| 29 | |
| 30 | const int i11 = data_c[i1 + i2 * p.s21]; |
| 31 | |
| 32 | const uint s1 = p.ne0; |
| 33 | const uint s2 = p.ne0 * p.ne1; |
| 34 | |
| 35 | const uint d0 = i1 * s1 + i2 * s2; |
| 36 | const uint a0 = i1 * p.s01 + i2 * p.s02; |
| 37 | |
| 38 | if (i11 == -1) { // skipped slot, add nothing |
| 39 | for (uint i0 = gl_LocalInvocationID.x; i0 < p.ne0; i0 += BLOCK_SIZE) { |
| 40 | data_d[d0 + i0] = data_a[a0 + i0]; |
| 41 | } |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | const uint b0 = uint(i11) * p.s11; |
| 46 | |
| 47 | for (uint i0 = gl_LocalInvocationID.x; i0 < p.ne0; i0 += BLOCK_SIZE) { |
| 48 | data_d[d0 + i0] = data_a[a0 + i0] + data_b[b0 + i0]; |
| 49 | } |
| 50 | } |