Skip to content

LLM inference in C/C++

C++ ggml

graph: keep the graph non empty without embeddings (#30522)

Pascal1ddc262558fe
diff --git a/src/llama-graph.cpp b/src/llama-graph.cpp
index f69fe63f8f..6cadda9716 100644
--- a/src/llama-graph.cpp
+++ b/src/llama-graph.cpp
@@ -3978,6 +3978,10 @@ void llm_graph_context::build_pooling(
ggml_tensor * cls_out_b,
ggml_tensor * cls_norm) const {
if (!cparams.embeddings) {
+ // a graph without logits still computes t_embd, so that it is never empty
+ if (res->t_logits == nullptr && res->t_embd != nullptr) {
+ ggml_build_forward_expand(gf, res->t_embd);
+ }
return;
}