From e73690a69d36362f0237727b25843f95c3ff5f1b Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 22 Jun 2025 18:45:07 +0300 Subject: [PATCH] ggml : ggml_set_rows update comment + better index name --- ggml/include/ggml.h | 2 ++ ggml/src/ggml-cpu/ops.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ggml/include/ggml.h b/ggml/include/ggml.h index b9a8d37715..2b1bd6e0f4 100644 --- a/ggml/include/ggml.h +++ b/ggml/include/ggml.h @@ -1383,6 +1383,8 @@ extern "C" { // b TS [n_embd, n_rows, ne02, ne03] | ne02 == ne2, ne03 == ne3 // c I64 [n_rows, ne11, ne12, 1] | c[i] in [0, ne1) // + // undefined behavior if destination rows overlap + // // broadcast: // ne2 % ne11 == 0 // ne3 % ne12 == 0 diff --git a/ggml/src/ggml-cpu/ops.cpp b/ggml/src/ggml-cpu/ops.cpp index e9832f8dee..8a51e4cf3a 100644 --- a/ggml/src/ggml-cpu/ops.cpp +++ b/ggml/src/ggml-cpu/ops.cpp @@ -4558,13 +4558,13 @@ static void ggml_compute_forward_set_rows_f32( const int64_t i11 = i02%ne11; const int64_t i10 = i; - const int64_t i01 = *(int64_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12); + const int64_t i1 = *(int64_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12); - GGML_ASSERT(i01 >= 0 && i01 < ne1); + GGML_ASSERT(i1 >= 0 && i1 < ne1); from_float( - (const float *) ((char *) src0->data + i*nb01 + i02*nb02 + i03*nb03), - ((char *) dst->data + i01*nb1 + i02*nb2 + i03*nb3), nc); + (const float *) ((char *) src0->data + i*nb01 + i02*nb02 + i03*nb03), + ((char *) dst->data + i1*nb1 + i02*nb2 + i03*nb3), nc); } } }