llama : add struct llama_kv_cache (wip) [no ci]
This commit is contained in:
parent
178a7eb952
commit
f78b396ee7
8 changed files with 428 additions and 415 deletions
|
@ -171,8 +171,10 @@ llama_tokens common_speculative_gen_draft(
|
|||
llama_tokens result;
|
||||
result.reserve(params.n_draft);
|
||||
|
||||
llama_kv_cache * kv = llama_get_kv_cache(ctx);
|
||||
|
||||
if (reuse_n == 0) {
|
||||
llama_kv_cache_clear(ctx);
|
||||
llama_kv_cache_clear(kv);
|
||||
|
||||
prompt.clear();
|
||||
} else {
|
||||
|
@ -191,14 +193,14 @@ llama_tokens common_speculative_gen_draft(
|
|||
}
|
||||
|
||||
if (reuse_i > 0) {
|
||||
llama_kv_cache_seq_rm (ctx, 0, 0, reuse_i);
|
||||
llama_kv_cache_seq_add(ctx, 0, reuse_i, -1, -reuse_i);
|
||||
llama_kv_cache_seq_rm (kv, 0, 0, reuse_i);
|
||||
llama_kv_cache_seq_add(kv, 0, reuse_i, -1, -reuse_i);
|
||||
|
||||
prompt.erase(prompt.begin(), prompt.begin() + reuse_i);
|
||||
}
|
||||
|
||||
if (reuse_n < (int) prompt.size()) {
|
||||
llama_kv_cache_seq_rm (ctx, 0, reuse_n, -1);
|
||||
llama_kv_cache_seq_rm (kv, 0, reuse_n, -1);
|
||||
|
||||
prompt.erase(prompt.begin() + reuse_n, prompt.end());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue