Commit 9e7171624 for llama.cpp
commit 9e71716247113b47bb831d1e0680cbf5f242f094
Author: Chris Peterson <cpeterson@mozilla.com>
Date: Tue Sep 15 02:33:26 2026 -0700
models : move build_arch_graph() after graph() template specialization (#28934)
Move build_arch_graph()'s function definitions after the graph<true>
and graph<false> template specializations have been explicitly defined.
diff --git a/src/models/dflash.cpp b/src/models/dflash.cpp
index da84f30b6..ed5366d80 100644
--- a/src/models/dflash.cpp
+++ b/src/models/dflash.cpp
@@ -240,21 +240,6 @@ void llama_model_dflash::load_arch_tensors(llama_model_loader &) {
}
}
-std::unique_ptr<llm_graph_context> llama_model_dflash::build_arch_graph(const llm_graph_params & params) const {
- switch (params.gtype) {
- case LLM_GRAPH_TYPE_ENCODER:
- return std::make_unique<graph<true>>(*this, params);
- case LLM_GRAPH_TYPE_DEFAULT:
- case LLM_GRAPH_TYPE_DECODER:
- if (hparams.dsv4_hc_mult > 0) {
- return std::make_unique<graph_dsv4>(*this, params);
- }
- return std::make_unique<graph<false>>(*this, params);
- default:
- GGML_ABORT("invalid graph type");
- };
-}
-
template <>
ggml_tensor * llama_model_dflash::graph<true>::build_inp_embd_enc() const {
const int64_t n_embd_inp = hparams.n_embd_inp_enc();
@@ -999,3 +984,18 @@ llama_model_dflash::graph_dsv4::graph_dsv4(const llama_model & model, const llm_
build_dspark_markov_head(*this, model, inp_tokens);
}
}
+
+std::unique_ptr<llm_graph_context> llama_model_dflash::build_arch_graph(const llm_graph_params & params) const {
+ switch (params.gtype) {
+ case LLM_GRAPH_TYPE_ENCODER:
+ return std::make_unique<graph<true>>(*this, params);
+ case LLM_GRAPH_TYPE_DEFAULT:
+ case LLM_GRAPH_TYPE_DECODER:
+ if (hparams.dsv4_hc_mult > 0) {
+ return std::make_unique<graph_dsv4>(*this, params);
+ }
+ return std::make_unique<graph<false>>(*this, params);
+ default:
+ GGML_ABORT("invalid graph type");
+ };
+}
diff --git a/src/models/eagle3.cpp b/src/models/eagle3.cpp
index be466056d..bfde35e43 100644
--- a/src/models/eagle3.cpp
+++ b/src/models/eagle3.cpp
@@ -100,18 +100,6 @@ void llama_model_eagle3::load_arch_tensors(llama_model_loader &) {
}
}
-std::unique_ptr<llm_graph_context> llama_model_eagle3::build_arch_graph(const llm_graph_params & params) const {
- switch (params.gtype) {
- case LLM_GRAPH_TYPE_ENCODER:
- return std::make_unique<graph<true>>(*this, params);
- case LLM_GRAPH_TYPE_DEFAULT:
- case LLM_GRAPH_TYPE_DECODER:
- return std::make_unique<graph<false>>(*this, params);
- default:
- GGML_ABORT("invalid graph type");
- };
-}
-
template <>
ggml_tensor * llama_model_eagle3::graph<true>::build_inp_embd_enc() const {
ggml_tensor * cur = nullptr;
@@ -336,3 +324,15 @@ llama_model_eagle3::graph<false>::graph(const llama_model & model, const llm_gra
ggml_build_forward_expand(gf, cur);
}
+
+std::unique_ptr<llm_graph_context> llama_model_eagle3::build_arch_graph(const llm_graph_params & params) const {
+ switch (params.gtype) {
+ case LLM_GRAPH_TYPE_ENCODER:
+ return std::make_unique<graph<true>>(*this, params);
+ case LLM_GRAPH_TYPE_DEFAULT:
+ case LLM_GRAPH_TYPE_DECODER:
+ return std::make_unique<graph<false>>(*this, params);
+ default:
+ GGML_ABORT("invalid graph type");
+ };
+}
diff --git a/src/models/t5.cpp b/src/models/t5.cpp
index b0e3f0625..e2bf12b6b 100644
--- a/src/models/t5.cpp
+++ b/src/models/t5.cpp
@@ -106,18 +106,6 @@ void llama_model_t5::load_arch_tensors(llama_model_loader &) {
}
}
-std::unique_ptr<llm_graph_context> llama_model_t5::build_arch_graph(const llm_graph_params & params) const {
- switch (params.gtype) {
- case LLM_GRAPH_TYPE_ENCODER:
- return std::make_unique<graph<true>>(*this, params);
- case LLM_GRAPH_TYPE_DEFAULT:
- case LLM_GRAPH_TYPE_DECODER:
- return std::make_unique<graph<false>>(*this, params);
- default:
- GGML_ABORT("invalid graph type");
- };
-}
-
template <>
llama_model_t5::graph<false>::graph(const llama_model & model, const llm_graph_params & params) : llm_graph_context(params) {
const int64_t n_embd_head = hparams.n_embd_head_v();
@@ -368,3 +356,15 @@ llama_model_t5::graph<true>::graph(const llama_model & model, const llm_graph_pa
ggml_build_forward_expand(gf, cur);
}
+
+std::unique_ptr<llm_graph_context> llama_model_t5::build_arch_graph(const llm_graph_params & params) const {
+ switch (params.gtype) {
+ case LLM_GRAPH_TYPE_ENCODER:
+ return std::make_unique<graph<true>>(*this, params);
+ case LLM_GRAPH_TYPE_DEFAULT:
+ case LLM_GRAPH_TYPE_DECODER:
+ return std::make_unique<graph<false>>(*this, params);
+ default:
+ GGML_ABORT("invalid graph type");
+ };
+}