From 5a44324e4a3cdee1dc20bf9b9693164937c1b12f Mon Sep 17 00:00:00 2001 From: Kawrakow Date: Fri, 6 Feb 2026 06:56:09 +0200 Subject: [PATCH] Bespoke ggml_repeat for Step3.5-Flash (#1239) --- ggml/src/ggml.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 9937a480..191bdcd1 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -13960,6 +13960,22 @@ static void ggml_compute_forward_repeat_f32( const struct ggml_tensor * src0 = dst->src[0]; + if (ggml_is_contiguous(src0) && ggml_is_contiguous(dst) && src0->ne[0] == 1 && ggml_nrows(src0) == ggml_nrows(dst)) { + int ith = params->ith; + int nth = params->nth; + int nr = ggml_nrows(dst); + int nc = dst->ne[0]; + int dr = (nr + nth - 1)/nth; + int ir0 = dr*ith; + int ir1 = MIN(nr, ir0 + dr); + const float * x = (const float *)src0->data; + for (int ir = ir0; ir < ir1; ++ir) { + float * y = (float *)((char *)dst->data + ir*dst->nb[1]); + for (int j = 0; j < nc; ++j) y[j] = x[ir]; + } + return; + } + if (params->ith != 0) { return; }