graph : avoid reallocations in the "no cache" path (#30439)
This commit is contained in:
1 parent
af50f2f248
commit
9880157881
4 files changed
+13
-8
No files matched your search
+7
-1
@@ -73,11 +73,17 @@ llama_model_bert::graph::graph(const llama_model & model, const llm_graph_params
|
||||
ggml_tensor * cur;
|
||||
ggml_tensor * inpL;
|
||||
ggml_tensor * inp_pos = nullptr;
|
||||
ggml_tensor * embd_pos = nullptr;
|
||||
|
||||
if (model.arch != LLM_ARCH_JINA_BERT_V2) {
|
||||
inp_pos = build_inp_pos();
|
||||
}
|
||||
|
||||
if (model.arch == LLM_ARCH_BERT) {
|
||||
embd_pos = ggml_get_rows(ctx0, model.pos_embd, inp_pos);
|
||||
ggml_build_forward_order(gf, embd_pos);
|
||||
}
|
||||
|
||||
// construct input embeddings (token, type, position)
|
||||
inpL = build_inp_embd(model.tok_embd);
|
||||
|
||||
@@ -87,7 +93,7 @@ llama_model_bert::graph::graph(const llama_model & model, const llm_graph_params
|
||||
inpL = ggml_add(ctx0, inpL, type_row0);
|
||||
}
|
||||
if (model.arch == LLM_ARCH_BERT) {
|
||||
inpL = ggml_add(ctx0, ggml_get_rows(ctx0, model.pos_embd, inp_pos), inpL);
|
||||
inpL = ggml_add(ctx0, embd_pos, inpL);
|
||||
}
|
||||
cb(inpL, "inp_embd", -1);
|
||||
|
||||
|
||||
Reference in new issue
Block a user