Skip to content

Commit 3f93a00

Browse files
committed
quantize-stats : fix test + add it to Makefile default
1 parent a520b33 commit 3f93a00

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ $(info I CC: $(CCV))
133133
$(info I CXX: $(CXXV))
134134
$(info )
135135

136-
default: main quantize perplexity embedding
136+
default: main quantize quantize-stats perplexity embedding
137137

138138
#
139139
# Build library

examples/quantize-stats/quantize-stats.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <unordered_map>
1717
#include <vector>
1818

19-
static const char * type_strs[] = { "q4_0", "q4_1", "i8", "i16", "i32", "f16", "f32" };
19+
static const char * type_strs[] = { "f32", "f16", "q4_0", "q4_1", "q8_0", "i8", "i16", "i32", };
2020
static_assert(sizeof(type_strs) == GGML_TYPE_COUNT * sizeof(char *), "Incomplete type list");
2121

2222
struct quantize_stats_params {

ggml.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7033,14 +7033,16 @@ static void ggml_compute_forward_mul_mat_f16_f32(
70337033
static const quantize_fns_t quantize_fns[GGML_TYPE_COUNT] = {
70347034
[GGML_TYPE_Q4_0] = {
70357035
.dequantize_row_q = dequantize_row_q4_0,
7036-
.quantize_row_q = quantize_row_q8_0,
7036+
.quantize_row_q = quantize_row_q4_0,
70377037
.quantize_row_q_reference = (quantize_row_q_t) quantize_row_q4_0_reference,
7038+
.quantize_row_q_dot = quantize_row_q8_0,
70387039
.vec_dot_q = ggml_vec_dot_q4_0_q8_0,
70397040
},
70407041
[GGML_TYPE_Q4_1] = {
70417042
.dequantize_row_q = dequantize_row_q4_1,
70427043
.quantize_row_q = quantize_row_q4_1,
70437044
.quantize_row_q_reference = (quantize_row_q_t) quantize_row_q4_1_reference,
7045+
.quantize_row_q_dot = quantize_row_q8_0,
70447046
.vec_dot_q = ggml_vec_dot_q4_1,
70457047
},
70467048
// TODO: GGML_TYPE_Q8_0
@@ -7099,8 +7101,8 @@ static void ggml_compute_forward_mul_mat_q_f32(
70997101
GGML_ASSERT(ne3 == ne13);
71007102

71017103
const enum ggml_type type = src0->type;
7102-
quantize_row_q_t const quantize_row_q = quantize_fns[type].quantize_row_q;
7103-
vec_dot_q_t const vec_dot_q = quantize_fns[type].vec_dot_q;
7104+
quantize_row_q_t const quantize_row_q_dot = quantize_fns[type].quantize_row_q_dot;
7105+
vec_dot_q_t const vec_dot_q = quantize_fns[type].vec_dot_q;
71047106

71057107
// we don't support permuted src0 or src1
71067108
GGML_ASSERT(nb00 == (int) GGML_TYPE_SIZE[type]);
@@ -7174,7 +7176,7 @@ static void ggml_compute_forward_mul_mat_q_f32(
71747176
for (int64_t i13 = 0; i13 < ne13; ++i13) {
71757177
for (int64_t i12 = 0; i12 < ne12; ++i12) {
71767178
for (int64_t i11 = 0; i11 < ne11; ++i11) {
7177-
quantize_row_q((float *)((char *) src1->data + i13*nb13 + i12*nb12 + i11*nb11), (void *) wdata, ne10);
7179+
quantize_row_q_dot((float *)((char *) src1->data + i13*nb13 + i12*nb12 + i11*nb11), (void *) wdata, ne10);
71787180
wdata += row_size;
71797181
}
71807182
}

ggml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ typedef struct {
817817
dequantize_row_q_t dequantize_row_q;
818818
quantize_row_q_t quantize_row_q;
819819
quantize_row_q_t quantize_row_q_reference;
820+
quantize_row_q_t quantize_row_q_dot;
820821
vec_dot_q_t vec_dot_q;
821822
} quantize_fns_t;
822823

0 commit comments

Comments
 (0)