op_getrows_q4_0.comp 919 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #version 450
  2. #include "common.comp"
  3. #define NL 2
  4. #define BYTES_FOR_TYPE 4 /*bytes for float*/
  5. #define SIZE_OF_BLOCK sizeof_block_q4_0
  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_q4_0 get_unaligned_block_q4_0(uint index) {
  19. block_q4_0 fres;
  20. fres.d = u8BufToFloat16(inA, index);
  21. [[unroll]] for (uint it = 0; it != QK4_0 / 2; it++) {
  22. fres.qs[it] = inA[index+2+it];
  23. }
  24. return fres;
  25. }
  26. mat4 dequantize_block(uint index, uint il) {
  27. const block_q4_0 block = get_unaligned_block_q4_0(index);
  28. return dequantize_q4_0(block, il);
  29. }
  30. #include "op_getrows.comp"