]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
fix: Move build_inp_pos to the top of the graph section for build_granite (#13538)
authorGabe Goodhart <redacted>
Wed, 14 May 2025 12:53:59 +0000 (06:53 -0600)
committerGitHub <redacted>
Wed, 14 May 2025 12:53:59 +0000 (15:53 +0300)
This matches how others do it, but will still avoid the extra
initialization when rope is disabled.

Branch: GraniteFour

Signed-off-by: Gabe Goodhart <redacted>
src/llama-model.cpp

index f652f4b861d1ffac74c39c5f2a017a7f7241768d..7fd094b63f26921ee06bae90c3c440b717f1dbee 100644 (file)
@@ -12218,6 +12218,9 @@ struct llm_build_granite : public llm_graph_context {
 
         // inp_pos - built only if rope enabled
         ggml_tensor * inp_pos = nullptr;
+        if (use_rope) {
+            inp_pos = build_inp_pos();
+        }
 
         auto * inp_attn = build_attn_inp_kv_unified();
 
@@ -12260,10 +12263,6 @@ struct llm_build_granite : public llm_graph_context {
                 Vcur = ggml_reshape_3d(ctx0, Vcur, n_embd_head, n_head_kv, n_tokens);
 
                 if (use_rope) {
-
-                    if (!inp_pos) {
-                        inp_pos = build_inp_pos();
-                    }
                     ggml_tensor * rope_factors = model.get_rope_factors(n_ctx_per_seq, il);
                     Qcur = ggml_rope_ext(
                             ctx0, Qcur, inp_pos, rope_factors,