char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
fcae601e4
char/aliceai-t5-moe
1#version 450 2 3#include "types.glsl" 4#include "generic_unary_head.glsl" 5 6#extension GL_EXT_control_flow_attributes : require 7 8const uint num_threads = 128; 9 10layout(local_size_x = num_threads, local_size_y = 1, local_size_z = 1) in; 11 12void main() { 13 uint idx = get_idx(); 14 15 // num_threads * num_iter must equal 512, to match the wg_denoms and get_idx calculation 16 const uint num_iter = 4; 17 18 // fast path for when all four iterations are in-bounds 19 if (idx + (num_iter-1)*num_threads < p.ne) { 20 [[unroll]] for (uint i = 0; i < num_iter; ++i) { 21 22#if defined(DATA_A_BF16) 23 data_d[get_doffset() + idx] = D_TYPE(bf16_to_fp32(uint32_t(data_a[get_aoffset() + idx]))); 24#elif defined(DATA_D_BF16) 25 float f = float(data_a[get_aoffset() + idx]); 26 data_d[get_doffset() + idx] = D_TYPE(fp32_to_bf16(f)); 27#elif !defined(OPTIMIZATION_ERROR_WORKAROUND) 28 data_d[get_doffset() + idx] = D_TYPE(data_a[get_aoffset() + idx]); 29#else 30 data_d[get_doffset() + idx] = data_a[get_aoffset() + idx]; 31#endif 32 idx += num_threads; 33 } 34 } else { 35 [[unroll]] for (uint i = 0; i < num_iter; ++i) { 36 if (idx >= p.ne) { 37 continue; 38 } 39 40#if defined(DATA_A_BF16) 41 data_d[get_doffset() + idx] = D_TYPE(bf16_to_fp32(uint32_t(data_a[get_aoffset() + idx]))); 42#elif defined(DATA_D_BF16) 43 float f = float(data_a[get_aoffset() + idx]); 44 data_d[get_doffset() + idx] = D_TYPE(fp32_to_bf16(f)); 45#elif !defined(OPTIMIZATION_ERROR_WORKAROUND) 46 data_d[get_doffset() + idx] = D_TYPE(data_a[get_aoffset() + idx]); 47#else 48 data_d[get_doffset() + idx] = data_a[get_aoffset() + idx]; 49#endif 50 idx += num_threads; 51 } 52 } 53}