Skip to content

Commit b0597b1

Browse files
committed
ggml : fix cpy op for IQ-quants to use reference impl
ggml-ci
1 parent 382bc7f commit b0597b1

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

ggml/src/ggml-cpu/ggml-cpu.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,8 +2968,12 @@ static void ggml_compute_forward_dup_f16(
29682968
id += ne00 * (ne01 - ir1);
29692969
}
29702970
}
2971-
} else if (ggml_get_type_traits_cpu(dst->type)->from_float) {
2972-
ggml_from_float_t const quantize_row_q = ggml_get_type_traits_cpu(dst->type)->from_float;
2971+
} else if (ggml_get_type_traits_cpu(dst->type)->from_float || ggml_get_type_traits(dst->type)->from_float_ref) {
2972+
ggml_from_float_t quantize_row_q = ggml_get_type_traits_cpu(dst->type)->from_float;
2973+
if (!quantize_row_q) {
2974+
quantize_row_q = ggml_get_type_traits(dst->type)->from_float_ref;
2975+
}
2976+
29732977
float * src0_f32 = (float *) params->wdata + (ne00 + CACHE_LINE_SIZE_F32) * ith;
29742978

29752979
size_t id = 0;
@@ -3565,8 +3569,11 @@ static void ggml_compute_forward_dup_f32(
35653569
id += rs * (ne01 - ir1);
35663570
}
35673571
}
3568-
} else if (ggml_get_type_traits_cpu(dst->type)->from_float) {
3569-
ggml_from_float_t const quantize_row_q = ggml_get_type_traits_cpu(dst->type)->from_float;
3572+
} else if (ggml_get_type_traits_cpu(dst->type)->from_float || ggml_get_type_traits(dst->type)->from_float_ref) {
3573+
ggml_from_float_t quantize_row_q = ggml_get_type_traits_cpu(dst->type)->from_float;
3574+
if (!quantize_row_q) {
3575+
quantize_row_q = ggml_get_type_traits(dst->type)->from_float_ref;
3576+
}
35703577

35713578
size_t id = 0;
35723579
size_t rs = nb0 * (ne00 / ggml_blck_size(dst->type));

tests/test-backend-ops.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,8 +3549,11 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
35493549

35503550
for (ggml_type type_src : {GGML_TYPE_F16, GGML_TYPE_F32}) {
35513551
for (ggml_type type_dst : all_types) {
3552-
test_cases.emplace_back(new test_cpy(type_src, type_dst, {256, 4, 4, 4}));
3553-
test_cases.emplace_back(new test_cpy(type_src, type_dst, {256, 2, 3, 4}, {0, 2, 1, 3})); // cpy by rows
3552+
//if (type_dst == GGML_TYPE_IQ2_S || type_dst == GGML_TYPE_IQ3_XXS || type_dst == GGML_TYPE_IQ3_S) {
3553+
// continue;
3554+
//}
3555+
test_cases.emplace_back(new test_cpy(type_src, type_dst, {256, 4, 4, 4}));
3556+
test_cases.emplace_back(new test_cpy(type_src, type_dst, {256, 2, 3, 4}, {0, 2, 1, 3})); // cpy by rows
35543557
}
35553558
}
35563559
for (ggml_type type_src : {GGML_TYPE_F16, GGML_TYPE_F32}) {

0 commit comments

Comments
 (0)