Skip to content

Commit f7aac82

Browse files
fairydreamingsszymczy
authored andcommitted
llama : check all graph nodes when searching for result_embd_pooled (ggml-org#8956)
Co-authored-by: Stanisław Szymczyk <[email protected]>
1 parent a76ca96 commit f7aac82

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/llama.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14726,12 +14726,15 @@ static int llama_decode_internal(
1472614726
res = nullptr;
1472714727
embd = nullptr;
1472814728
} else if (cparams.embeddings) {
14729-
res = nullptr; // do not extract logits for embedding case
14730-
embd = gf->nodes[gf->n_nodes - 1];
14731-
if (strcmp(embd->name, "result_embd_pooled") != 0) {
14732-
embd = gf->nodes[gf->n_nodes - 2];
14729+
res = nullptr; // do not extract logits for embedding case
14730+
embd = nullptr;
14731+
for (int i = gf->n_nodes - 1; i >= 0; --i) {
14732+
if (strcmp(gf->nodes[i]->name, "result_embd_pooled") == 0) {
14733+
embd = gf->nodes[i];
14734+
break;
14735+
}
1473314736
}
14734-
GGML_ASSERT(strcmp(embd->name, "result_embd_pooled") == 0 && "missing embeddings tensor");
14737+
GGML_ASSERT(embd != nullptr && "missing embeddings tensor");
1473514738
} else {
1473614739
embd = nullptr; // do not extract embeddings when not needed
1473714740
GGML_ASSERT(strcmp(res->name, "result_output") == 0 && "missing result_output tensor");

0 commit comments

Comments
 (0)