← Back to C-Kernel-Engine Docs Doxygen Source Documentation
Loading...
Searching...
No Matches
packed_q8_dot_ordered.h
Go to the documentation of this file.
1#ifndef CK_PACKED_Q8_DOT_ORDERED_H
2#define CK_PACKED_Q8_DOT_ORDERED_H
3
4#include "ckernel_quant.h"
5
6static inline float ck_packed_q8_dot_ordered(const float *input, const unsigned char *weight,
7 size_t width)
8{
9 double sum = 0.0;
10 for (size_t i = 0; i < width; i += QK8_0, weight += sizeof(block_q8_0)) {
11 const float scale = ck_fp16_to_fp32_soft((uint16_t)(weight[0] | ((uint16_t)weight[1] << 8)));
12 for (size_t j = 0; j < QK8_0; ++j) {
13 const int code = weight[j + 2];
14 const float value = scale * (float)(code < 128 ? code : code - 256);
15 sum += (double)input[i + j] * (double)value;
16 }
17 }
18 return (float)sum;
19}
20
21#endif
Quantization block structures for weight-only quantization.
static float ck_fp16_to_fp32_soft(ck_half h)
Convert FP16 (ck_half) to FP32 — software implementation.
#define QK8_0
static float ck_packed_q8_dot_ordered(const float *input, const unsigned char *weight, size_t width)