Team Ai
Apppublic

KBaba7/llama.cpp

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
sum_rows.comp38 linesDownload Raw Back to vulkan-shaders
1#version 4502 3#include "generic_head.comp"4#include "types.comp"5 6#extension GL_EXT_control_flow_attributes : enable7layout(local_size_x_id = 0, local_size_y = 1, local_size_z = 1) in;8 9layout (binding = 0) readonly buffer A {A_TYPE data_a[];};10layout (binding = 1) writeonly buffer D {D_TYPE data_d[];};11 12layout (constant_id = 0) const uint BLOCK_SIZE = 32;13 14shared FLOAT_TYPE tmp[BLOCK_SIZE];15 16void main() {17    const uint row = gl_WorkGroupID.z * 262144 + gl_WorkGroupID.y * 512 + gl_WorkGroupID.x;18    const uint col = gl_LocalInvocationID.x;19 20    tmp[col] = FLOAT_TYPE(0.0f);21 22    for (uint i = col; i < p.KX; i += BLOCK_SIZE) {23        tmp[col] += FLOAT_TYPE(data_a[row*p.KX + i]);24    }25 26    barrier();27    [[unroll]] for (int s = int(BLOCK_SIZE) / 2; s > 0; s >>= 1) {28        if (col < s) {29            tmp[col] += tmp[col + s];30        }31        barrier();32    }33 34    if (col == 0) {35        data_d[row] = D_TYPE(tmp[0]);36    }37}38