Skip to content

Commit cd2dbea

Browse files
committed
Use the work buffer instead to fix MSVC build
1 parent 9ac84e1 commit cd2dbea

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

ggml.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -5352,6 +5352,8 @@ static void ggml_compute_forward_add_q_f32(
53525352
const int ir0 = dr*ith;
53535353
const int ir1 = MIN(ir0 + dr, nr);
53545354

5355+
float * wdata = (float*) params->wdata + ne00 * ith;
5356+
53555357
for (int ir = ir0; ir < ir1; ++ir) {
53565358
// src0 indices
53575359
const int i03 = ir/(ne02*ne01);
@@ -5374,12 +5376,11 @@ static void ggml_compute_forward_add_q_f32(
53745376
assert(ne00 % 32 == 0);
53755377

53765378
// unquantize row from src0 to temp buffer
5377-
float tmp[ne00];
5378-
dequantize_row_q(src0_row, tmp, ne00);
5379+
dequantize_row_q(src0_row, wdata, ne00);
53795380
// add src1
5380-
ggml_vec_acc_f32(ne00, tmp, src1_row);
5381+
ggml_vec_acc_f32(ne00, wdata, src1_row);
53815382
// quantize row to dst
5382-
quantize_row_q(tmp, dst_row, ne00);
5383+
quantize_row_q(wdata, dst_row, ne00);
53835384
}
53845385
}
53855386

@@ -9568,6 +9569,14 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph)
95689569
case GGML_OP_ADD:
95699570
{
95709571
node->n_tasks = n_threads;
9572+
9573+
size_t cur = 0;
9574+
9575+
if (node->src0->type == GGML_TYPE_Q4_0 || node->src0->type == GGML_TYPE_Q4_1) {
9576+
cur = GGML_TYPE_SIZE[GGML_TYPE_F32] * node->src0->ne[0] * n_threads;
9577+
}
9578+
9579+
work_size = MAX(work_size, cur);
95719580
} break;
95729581
case GGML_OP_SUB:
95739582
case GGML_OP_MUL:

0 commit comments

Comments
 (0)