ggml-omega
aien-dev/ggml-omega
Brought by drakestapleton
ggml-omega / kernels / dq8.om
| 1 | note dq8_@B@: q8_0 dot over @B@ blocks of 34 bytes (f16 scale d, 32 signed bytes q) against f32 x: |
| 2 | note acc (f64 bits) + sum over blocks of f64(d * sum_j f32(q_j)*x_j); fin 1 returns the f32 total. |
| 3 | fn q8s u uchar to f32 |
| 4 | q = long u |
| 5 | if ge q 128 |
| 6 | q = sub q 256 |
| 7 | end |
| 8 | ret f32 q |
| 9 | end |
| 10 | fn q8d w view uchar @W@ o ulong to f32 |
| 11 | ret h2f ushort or ulong get w o shl ulong get w add o 1 8 |
| 12 | end |
| 13 | fn dq8_@B@ acc ulong w view uchar @W@ x view f32 @X@ fin ulong to ulong |
| 14 | s = bitcast f64 acc |
| 15 | for b ulong @B@ |
| 16 | o = mul b 34 |
| 17 | xo = mul b 32 |
| 18 | bs = f32 0.0 |
| 19 | for j ulong 32 |
| 20 | bs = add bs mul q8s get w add add o 2 j get x add xo j |
| 21 | end |
| 22 | s = add s f64 mul q8d view w o bs |
| 23 | end |
| 24 | if eq fin 1 |
| 25 | ret ulong bitcast uint f32 s |
| 26 | end |
| 27 | ret bitcast ulong s |
| 28 | end |