← Back to C-Kernel-Engine Docs Doxygen Source Documentation
Loading...
Searching...
No Matches
packed_q8_dot_ordered.h File Reference
#include "ckernel_quant.h"

Go to the source code of this file.

Functions

static float ck_packed_q8_dot_ordered (const float *input, const unsigned char *weight, size_t width)

Function Documentation

◆ ck_packed_q8_dot_ordered()

float ck_packed_q8_dot_ordered ( const float * input,
const unsigned char * weight,
size_t width )
inlinestatic

Definition at line 6 of file packed_q8_dot_ordered.h.

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}
static float ck_fp16_to_fp32_soft(ck_half h)
Convert FP16 (ck_half) to FP32 — software implementation.
#define QK8_0

References ck_fp16_to_fp32_soft(), and QK8_0.

Referenced by expert_dot(), and linear_rows_q8_0_checked().