Merge commit 'f1e3eb4249' into concedo_experimental

# Conflicts:
#	.github/workflows/build.yml
#	README.md
#	docs/backend/SYCL.md
#	examples/llava/clip.cpp
#	ggml/src/ggml-sycl/CMakeLists.txt
#	ggml/src/ggml-vulkan/cmake/host-toolchain.cmake.in
This commit is contained in:
Concedo 2025-04-08 20:48:53 +08:00
commit 822cf2430e
26 changed files with 1822 additions and 2088 deletions

View file

@ -2475,7 +2475,12 @@ int32_t llama_get_kv_cache_token_count(const llama_context * ctx) {
}
int32_t llama_kv_self_n_tokens(const llama_context * ctx) {
return llama_kv_cache_n_tokens(ctx->get_kv_self());
const auto * kv = ctx->get_kv_self();
if (!kv) {
return 0;
}
return kv->get_n_tokens();
}
// deprecated
@ -2484,7 +2489,12 @@ int32_t llama_get_kv_cache_used_cells(const llama_context * ctx) {
}
int32_t llama_kv_self_used_cells(const llama_context * ctx) {
return llama_kv_cache_used_cells(ctx->get_kv_self());
const auto * kv = ctx->get_kv_self();
if (!kv) {
return 0;
}
return kv->get_used_cells();
}
// deprecated
@ -2493,7 +2503,12 @@ void llama_kv_cache_clear(llama_context * ctx) {
}
void llama_kv_self_clear(llama_context * ctx) {
llama_kv_cache_clear(ctx->get_kv_self());
auto * kv = ctx->get_kv_self();
if (!kv) {
return;
}
kv->clear();
}
// deprecated
@ -2510,7 +2525,12 @@ bool llama_kv_self_seq_rm(
llama_seq_id seq_id,
llama_pos p0,
llama_pos p1) {
return llama_kv_cache_seq_rm(ctx->get_kv_self(), seq_id, p0, p1);
auto * kv = ctx->get_kv_self();
if (!kv) {
return true;
}
return kv->seq_rm(seq_id, p0, p1);
}
// deprecated
@ -2529,7 +2549,12 @@ void llama_kv_self_seq_cp(
llama_seq_id seq_id_dst,
llama_pos p0,
llama_pos p1) {
return llama_kv_cache_seq_cp(ctx->get_kv_self(), seq_id_src, seq_id_dst, p0, p1);
auto * kv = ctx->get_kv_self();
if (!kv) {
return;
}
return kv->seq_cp(seq_id_src, seq_id_dst, p0, p1);
}
// deprecated
@ -2540,7 +2565,12 @@ void llama_kv_cache_seq_keep(
}
void llama_kv_self_seq_keep(llama_context * ctx, llama_seq_id seq_id) {
return llama_kv_cache_seq_keep(ctx->get_kv_self(), seq_id);
auto * kv = ctx->get_kv_self();
if (!kv) {
return;
}
return kv->seq_keep(seq_id);
}
// deprecated
@ -2559,7 +2589,12 @@ void llama_kv_self_seq_add(
llama_pos p0,
llama_pos p1,
llama_pos delta) {
return llama_kv_cache_seq_add(ctx->get_kv_self(), seq_id, p0, p1, delta);
auto * kv = ctx->get_kv_self();
if (!kv) {
return;
}
return kv->seq_add(seq_id, p0, p1, delta);
}
// deprecated
@ -2578,7 +2613,12 @@ void llama_kv_self_seq_div(
llama_pos p0,
llama_pos p1,
int d) {
return llama_kv_cache_seq_div(ctx->get_kv_self(), seq_id, p0, p1, d);
auto * kv = ctx->get_kv_self();
if (!kv) {
return;
}
return kv->seq_div(seq_id, p0, p1, d);
}
// deprecated
@ -2587,7 +2627,12 @@ llama_pos llama_kv_cache_seq_pos_max(llama_context * ctx, llama_seq_id seq_id) {
}
llama_pos llama_kv_self_seq_pos_max(llama_context * ctx, llama_seq_id seq_id) {
return llama_kv_cache_seq_pos_max(ctx->get_kv_self(), seq_id);
const auto * kv = ctx->get_kv_self();
if (!kv) {
return 0;
}
return kv->seq_pos_max(seq_id);
}
// deprecated
@ -2596,7 +2641,12 @@ void llama_kv_cache_defrag(llama_context * ctx) {
}
void llama_kv_self_defrag(llama_context * ctx) {
llama_kv_cache_defrag(ctx->get_kv_self());
auto * kv = ctx->get_kv_self();
if (!kv) {
return;
}
return kv->defrag();
}
// deprecated
@ -2605,7 +2655,12 @@ bool llama_kv_cache_can_shift(const llama_context * ctx) {
}
bool llama_kv_self_can_shift(const llama_context * ctx) {
return llama_kv_cache_can_shift(ctx->get_kv_self());
const auto * kv = ctx->get_kv_self();
if (!kv) {
return false;
}
return kv->get_can_shift();
}
// deprecated