op_getrows_q6_k.comp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #version 450
  2. #include "common.comp"
  3. #define NL 16
  4. #define BYTES_FOR_TYPE 4 /*bytes for float*/
  5. #define SIZE_OF_BLOCK sizeof_block_q6_k
  6. layout(local_size_x = 1) in;
  7. layout (binding = 0) readonly buffer tensorInA { uint8_t inA[]; };
  8. layout (binding = 1) readonly buffer tensorInB { int inB[]; };
  9. layout (binding = 2) writeonly buffer tensorOut { float out_[]; };
  10. layout (push_constant) uniform parameter {
  11. uint inAOff;
  12. uint inBOff;
  13. uint outOff;
  14. int ne00;
  15. int nb01;
  16. int nb1;
  17. } pcs;
  18. block_q6_k get_unaligned_block_q6_k(uint index) {
  19. block_q6_k fres;
  20. [[unroll]] for (uint it = 0; it != QK_K / 2; it++) {
  21. fres.ql[it] = inA[index + it];
  22. }
  23. [[unroll]] for (uint it = 0; it != QK_K / 4; it++) {
  24. fres.qh[it] = inA[index + QK_K/2 + it];
  25. }
  26. [[unroll]] for (uint it = 0; it != QK_K / 16; it++) {
  27. fres.scales[it] = int8_t(inA[index + QK_K/2 + QK_K/4 + it]);
  28. }
  29. fres.d = u8BufToFloat16(inA, index + QK_K/2 + QK_K/4 + QK_K/16);
  30. return fres;
  31. }
  32. mat4 dequantize_block(uint index, uint il) {
  33. const block_q6_k block = get_unaligned_block_q6_k(index);
  34. return dequantize_q6_k(block, il);
  35. }
  36. #include "op_getrows.comp"