Skip to content

Commit 5ea88de

Browse files
committed
Eliminate from_float_to_vec_dot
1 parent d21cb54 commit 5ea88de

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

ggml.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,63 +1981,55 @@ static const ggml_type_handling_t type_handling[GGML_TYPE_COUNT] = {
19811981
.to_float = (ggml_to_float_t) f16_to_float,
19821982
.from_float = (ggml_from_float_t) f16_from_float,
19831983
.from_float_reference = (ggml_from_float_t) f16_from_float,
1984-
.from_float_to_vec_dot = (ggml_from_float_t) f16_from_float,
19851984
.vec_dot = (ggml_vec_dot_t) ggml_vec_dot_f16,
19861985
.vec_dot_type = GGML_TYPE_F16,
19871986
},
19881987
[GGML_TYPE_Q4_0] = {
19891988
.to_float = dequantize_row_q4_0,
19901989
.from_float = quantize_row_q4_0,
19911990
.from_float_reference = (ggml_from_float_t) quantize_row_q4_0_reference,
1992-
.from_float_to_vec_dot = quantize_row_q8_0,
19931991
.vec_dot = ggml_vec_dot_q4_0_q8_0,
19941992
.vec_dot_type = GGML_TYPE_Q8_0,
19951993
},
19961994
[GGML_TYPE_Q4_1] = {
19971995
.to_float = dequantize_row_q4_1,
19981996
.from_float = quantize_row_q4_1,
19991997
.from_float_reference = (ggml_from_float_t) quantize_row_q4_1_reference,
2000-
.from_float_to_vec_dot = quantize_row_q8_1,
20011998
.vec_dot = ggml_vec_dot_q4_1_q8_1,
20021999
.vec_dot_type = GGML_TYPE_Q8_1,
20032000
},
20042001
[GGML_TYPE_Q4_2] = {
20052002
.to_float = dequantize_row_q4_2,
20062003
.from_float = quantize_row_q4_2,
20072004
.from_float_reference = (ggml_from_float_t) quantize_row_q4_2_reference,
2008-
.from_float_to_vec_dot = quantize_row_q8_0,
20092005
.vec_dot = ggml_vec_dot_q4_2_q8_0,
20102006
.vec_dot_type = GGML_TYPE_Q8_0,
20112007
},
20122008
[GGML_TYPE_Q5_0] = {
20132009
.to_float = dequantize_row_q5_0,
20142010
.from_float = quantize_row_q5_0,
20152011
.from_float_reference = (ggml_from_float_t) quantize_row_q5_0_reference,
2016-
.from_float_to_vec_dot = quantize_row_q8_0,
20172012
.vec_dot = ggml_vec_dot_q5_0_q8_0,
20182013
.vec_dot_type = GGML_TYPE_Q8_0,
20192014
},
20202015
[GGML_TYPE_Q5_1] = {
20212016
.to_float = dequantize_row_q5_1,
20222017
.from_float = quantize_row_q5_1,
20232018
.from_float_reference = (ggml_from_float_t) quantize_row_q5_1_reference,
2024-
.from_float_to_vec_dot = quantize_row_q8_1,
20252019
.vec_dot = ggml_vec_dot_q5_1_q8_1,
20262020
.vec_dot_type = GGML_TYPE_Q8_1,
20272021
},
20282022
[GGML_TYPE_Q8_0] = {
20292023
.to_float = dequantize_row_q8_0,
20302024
.from_float = quantize_row_q8_0,
20312025
.from_float_reference = (ggml_from_float_t) quantize_row_q8_0_reference,
2032-
.from_float_to_vec_dot = quantize_row_q8_0,
20332026
.vec_dot = ggml_vec_dot_q8_0_q8_0,
20342027
.vec_dot_type = GGML_TYPE_Q8_0,
20352028
},
20362029
[GGML_TYPE_Q8_1] = {
20372030
.to_float = NULL, // TODO
20382031
.from_float = quantize_row_q8_1,
20392032
.from_float_reference = (ggml_from_float_t) quantize_row_q8_1_reference,
2040-
.from_float_to_vec_dot = quantize_row_q8_1,
20412033
.vec_dot = NULL, // TODO
20422034
.vec_dot_type = GGML_TYPE_Q8_1,
20432035
},
@@ -8204,9 +8196,9 @@ static void ggml_compute_forward_mul_mat_q_f32(
82048196
GGML_ASSERT(ne3 == ne13);
82058197

82068198
const enum ggml_type type = src0->type;
8207-
ggml_from_float_t const from_float_to_vec_dot = type_handling[type].from_float_to_vec_dot;
82088199
ggml_vec_dot_t const vec_dot = type_handling[type].vec_dot;
82098200
enum ggml_type const vec_dot_type = type_handling[type].vec_dot_type;
8201+
ggml_from_float_t const from_float_to_vec_dot = type_handling[vec_dot_type].from_float;
82108202

82118203
// we don't support permuted src0 or src1
82128204
GGML_ASSERT(nb00 == (int) GGML_TYPE_SIZE[type]);

ggml.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ extern "C" {
883883
ggml_to_float_t to_float;
884884
ggml_from_float_t from_float;
885885
ggml_from_float_t from_float_reference;
886-
ggml_from_float_t from_float_to_vec_dot;
887886
ggml_vec_dot_t vec_dot;
888887
enum ggml_type vec_dot_type;
889888
} ggml_type_handling_t;

pocs/vdot/vdot.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ int main(int argc, char** argv) {
278278
dot_q4_q8(kVecSize, &result, q40.data(), q8.data());
279279
}
280280
else {
281-
funcs.from_float_to_vec_dot(y1.data(), q8.data(), kVecSize);
281+
auto vdot = ggml_internal_get_type_handling(funcs.vec_dot_type);
282+
vdot.from_float(y1.data(), q8.data(), kVecSize);
282283
if (useQ4_1) funcs.vec_dot(kVecSize, &result, q41.data(), q8.data());
283284
else funcs.vec_dot(kVecSize, &result, q40.data(), q8.data());
284285
}

tests/test-quantize-fns.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ float dot_product_error(ggml_type_handling_t & qfns, size_t test_size, const flo
7272
std::vector<uint8_t> tmp_q1(2*test_size);
7373
std::vector<uint8_t> tmp_q2(2*test_size);
7474

75-
qfns.from_float (test_data1, tmp_q1.data(), test_size);
76-
qfns.from_float_to_vec_dot(test_data2, tmp_q2.data(), test_size);
75+
auto vdot = ggml_internal_get_type_handling(qfns.vec_dot_type);
76+
77+
qfns.from_float(test_data1, tmp_q1.data(), test_size);
78+
vdot.from_float(test_data2, tmp_q2.data(), test_size);
7779

7880
float result = INFINITY;
7981
qfns.vec_dot(test_size, &result, tmp_q1.data(), tmp_q2.data());

tests/test-quantize-perf.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ int main(int argc, char * argv[]) {
276276
for (size_t size : params.test_sizes) {
277277
printf(" %zu values (%.2f MB)\n", size, 4*size/(float)(1024*1024));
278278
auto quantize_fn = [&](void ) {
279-
qfns.from_float_to_vec_dot(test_data1, test_q1, size);
279+
auto vdot = ggml_internal_get_type_handling(qfns.vec_dot_type);
280+
vdot.from_float(test_data1, test_q1, size);
280281
return test_q1[0];
281282
};
282283
size_t quantized_size = size / ggml_blck_size(type) * ggml_type_size(type);

0 commit comments

Comments
 (0)