Skip to content

Commit

Permalink
Use the work buffer instead to fix MSVC build
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren committed Apr 8, 2023
1 parent 4e07828 commit a4539e1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -5350,6 +5350,8 @@ static void ggml_compute_forward_add_q_f32(
const int ir0 = dr*ith;
const int ir1 = MIN(ir0 + dr, nr);

float * wdata = (float*) params->wdata + ne00 * ith;

for (int ir = ir0; ir < ir1; ++ir) {
// src0 indices
const int i03 = ir/(ne02*ne01);
Expand All @@ -5372,12 +5374,11 @@ static void ggml_compute_forward_add_q_f32(
assert(ne00 % 32 == 0);

// unquantize row from src0 to temp buffer
float tmp[ne00];
dequantize_row_q(src0_row, tmp, ne00);
dequantize_row_q(src0_row, wdata, ne00);
// add src1
ggml_vec_acc_f32(ne00, tmp, src1_row);
ggml_vec_acc_f32(ne00, wdata, src1_row);
// quantize row to dst
quantize_row_q(tmp, dst_row, ne00);
quantize_row_q(wdata, dst_row, ne00);
}
}

Expand Down Expand Up @@ -9566,6 +9567,14 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph)
case GGML_OP_ADD:
{
node->n_tasks = n_threads;

size_t cur = 0;

if (node->src0->type == GGML_TYPE_Q4_0 || node->src0->type == GGML_TYPE_Q4_1) {
cur = GGML_TYPE_SIZE[GGML_TYPE_F32] * node->src0->ne[0] * n_threads;
}

work_size = MAX(work_size, cur);
} break;
case GGML_OP_SUB:
case GGML_OP_MUL:
Expand Down

0 comments on commit a4539e1

Please sign in to comment.