op_getrows_f16.comp 787 B

12345678910111213141516171819202122232425262728293031
  1. #version 450
  2. #include "common.comp"
  3. layout(local_size_x = 1) in;
  4. layout (binding = 0) readonly buffer tensorInA { float16_t inA[]; };
  5. layout (binding = 1) readonly buffer tensorInB { int inB[]; };
  6. layout (binding = 2) writeonly buffer tensorOut { float out_[]; };
  7. layout (push_constant) uniform parameter {
  8. uint inAOff;
  9. uint inBOff;
  10. uint outOff;
  11. int ne00;
  12. int nb01;
  13. int nb1;
  14. } pcs;
  15. void dequantize_row_f16(uint x /*Based from inA unaligned*/, uint y /*Based from out_*/, int k) {
  16. for (int j = 0; j < k; j++) {
  17. out_[y + j] = inA[x + j];
  18. }
  19. }
  20. void main() {
  21. const uint i = gl_WorkGroupID.x;
  22. const int r = inB[i + pcs.inBOff];
  23. dequantize_row_f16(r*pcs.nb01/2/*bytes for float16*/ + pcs.inAOff, i*pcs.nb1/4 + pcs.outOff, pcs.ne00);
  24. }