Skip to content

Commit 4022e88

Browse files
committed
fix: build errors from upstream merge — extern linkage + switch coverage (#48)
1. extern "C" GGML_API double-extern: wrap with extern "C" { } block 2. Missing turbo types in clamp switch: add TURBO3_0/TURBO4_0/TURBO2_0 Fixes #48.
1 parent e3ae9b3 commit 4022e88

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

ggml/src/ggml-cpu/ops.cpp

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <cfloat>
1313
#include <cmath>
1414

15-
extern "C" GGML_API int turbo3_cpu_wht_group_size;
16-
1715
// ggml_compute_forward_dup
1816

1917
static void ggml_compute_forward_dup_same_cont(
@@ -682,6 +680,7 @@ void ggml_compute_forward_add(
682680
case GGML_TYPE_TQ2_0:
683681
case GGML_TYPE_TQ3_1S:
684682
case GGML_TYPE_TQ4_1S:
683+
case GGML_TYPE_TQ4_0:
685684
case GGML_TYPE_IQ2_XXS:
686685
case GGML_TYPE_IQ2_XS:
687686
case GGML_TYPE_IQ3_XXS:
@@ -1134,6 +1133,7 @@ void ggml_compute_forward_add1(
11341133
case GGML_TYPE_TQ2_0:
11351134
case GGML_TYPE_TQ3_1S:
11361135
case GGML_TYPE_TQ4_1S:
1136+
case GGML_TYPE_TQ4_0:
11371137
case GGML_TYPE_IQ2_XXS:
11381138
case GGML_TYPE_IQ2_XS:
11391139
case GGML_TYPE_IQ3_XXS:
@@ -1265,6 +1265,7 @@ void ggml_compute_forward_acc(
12651265
case GGML_TYPE_TQ2_0:
12661266
case GGML_TYPE_TQ3_1S:
12671267
case GGML_TYPE_TQ4_1S:
1268+
case GGML_TYPE_TQ4_0:
12681269
case GGML_TYPE_IQ2_XXS:
12691270
case GGML_TYPE_IQ2_XS:
12701271
case GGML_TYPE_IQ3_XXS:
@@ -4355,6 +4356,7 @@ void ggml_compute_forward_out_prod(
43554356
case GGML_TYPE_TQ2_0:
43564357
case GGML_TYPE_TQ3_1S:
43574358
case GGML_TYPE_TQ4_1S:
4359+
case GGML_TYPE_TQ4_0:
43584360
case GGML_TYPE_IQ2_XXS:
43594361
case GGML_TYPE_IQ2_XS:
43604362
case GGML_TYPE_IQ3_XXS:
@@ -4633,6 +4635,7 @@ void ggml_compute_forward_set(
46334635
case GGML_TYPE_TQ2_0:
46344636
case GGML_TYPE_TQ3_1S:
46354637
case GGML_TYPE_TQ4_1S:
4638+
case GGML_TYPE_TQ4_0:
46364639
case GGML_TYPE_IQ2_XXS:
46374640
case GGML_TYPE_IQ2_XS:
46384641
case GGML_TYPE_IQ3_XXS:
@@ -4858,6 +4861,7 @@ void ggml_compute_forward_get_rows(
48584861
case GGML_TYPE_TQ2_0:
48594862
case GGML_TYPE_TQ3_1S:
48604863
case GGML_TYPE_TQ4_1S:
4864+
case GGML_TYPE_TQ4_0:
48614865
case GGML_TYPE_IQ2_XXS:
48624866
case GGML_TYPE_IQ2_XS:
48634867
case GGML_TYPE_IQ3_XXS:
@@ -4942,6 +4946,7 @@ static void ggml_compute_forward_set_rows_f32(
49424946

49434947
// For turbo types: communicate WHT group size to the quantize function via global
49444948
if (dst->type == GGML_TYPE_TURBO3_0 || dst->type == GGML_TYPE_TURBO4_0 || dst->type == GGML_TYPE_TURBO2_0) {
4949+
extern int turbo3_cpu_wht_group_size;
49454950
int gs = 0;
49464951
memcpy(&gs, dst->op_params, sizeof(int));
49474952
turbo3_cpu_wht_group_size = (gs == 64 || gs == 128) ? gs : 0;
@@ -5592,6 +5597,7 @@ void ggml_compute_forward_clamp(
55925597
case GGML_TYPE_TQ2_0:
55935598
case GGML_TYPE_TQ3_1S:
55945599
case GGML_TYPE_TQ4_1S:
5600+
case GGML_TYPE_TQ4_0:
55955601
case GGML_TYPE_IQ2_XXS:
55965602
case GGML_TYPE_IQ2_XS:
55975603
case GGML_TYPE_IQ3_XXS:
@@ -9976,9 +9982,13 @@ static void ggml_compute_forward_rwkv_wkv6_f32(
99769982
const int ith = params->ith;
99779983
const int nth = params->nth;
99789984

9979-
const int h_start = (HEADS * (ith )) / nth;
9980-
const int h_end = ((HEADS * (ith + 1)) / nth < HEADS) ?
9981-
(HEADS * (ith + 1)) / nth : HEADS;
9985+
if (ith >= HEADS) {
9986+
return;
9987+
}
9988+
9989+
const int h_start = (HEADS * ith) / nth;
9990+
const int h_end = ((HEADS * (ith + 1)) / nth < HEADS) ?
9991+
(HEADS * (ith + 1)) / nth : HEADS;
99829992

99839993
float * k = (float *) dst->src[0]->data;
99849994
float * v = (float *) dst->src[1]->data;
@@ -10189,9 +10199,13 @@ static void ggml_compute_forward_gla_f32(
1018910199
const int ith = params->ith;
1019010200
const int nth = params->nth;
1019110201

10192-
const int h_start = (HEADS * (ith )) / nth;
10193-
const int h_end = ((HEADS * (ith + 1)) / nth < HEADS) ?
10194-
(HEADS * (ith + 1)) / nth : HEADS;
10202+
if (ith >= HEADS) {
10203+
return;
10204+
}
10205+
10206+
const int h_start = (HEADS * ith) / nth;
10207+
const int h_end = ((HEADS * (ith + 1)) / nth < HEADS) ?
10208+
(HEADS * (ith + 1)) / nth : HEADS;
1019510209

1019610210
float * k = (float *) dst->src[0]->data;
1019710211
float * v = (float *) dst->src[1]->data;
@@ -10746,9 +10760,13 @@ static void ggml_compute_forward_rwkv_wkv7_f32(
1074610760
const int ith = params->ith;
1074710761
const int nth = params->nth;
1074810762

10749-
const int h_start = (HEADS * (ith )) / nth;
10750-
const int h_end = ((HEADS * (ith + 1)) / nth < HEADS) ?
10751-
(HEADS * (ith + 1)) / nth : HEADS;
10763+
if (ith >= HEADS) {
10764+
return;
10765+
}
10766+
10767+
const int h_start = (HEADS * ith) / nth;
10768+
const int h_end = ((HEADS * (ith + 1)) / nth < HEADS) ?
10769+
(HEADS * (ith + 1)) / nth : HEADS;
1075210770

1075310771
float * r = (float *) dst->src[0]->data;
1075410772
float * w = (float *) dst->src[1]->data;

0 commit comments

Comments
 (0)