#include "llama-kv-cache-calrt-adapter.h" #include "ggml.h" llama_memory_context_ptr llama_kv_cache_calrt_adapter::init_batch(llama_batch_allocr & balloc, uint32_t n_ubatch, bool embd_all) { GGML_UNUSED(balloc); GGML_UNUSED(n_ubatch); GGML_UNUSED(embd_all); return nullptr; } llama_memory_context_ptr llama_kv_cache_calrt_adapter::init_full() { return nullptr; } llama_memory_context_ptr llama_kv_cache_calrt_adapter::init_update(llama_context * lctx, bool optimize) { GGML_UNUSED(lctx); GGML_UNUSED(optimize); return nullptr; } std::map llama_kv_cache_calrt_adapter::memory_breakdown() const { std::map ret; return ret; } bool llama_kv_cache_calrt_adapter::get_can_shift() const { return kv_manager->canShift(); } void llama_kv_cache_calrt_adapter::clear(bool data) { GGML_UNUSED(data); kv_manager->Clear(); } bool llama_kv_cache_calrt_adapter::seq_rm(llama_seq_id seq_id, llama_pos p0, llama_pos p1) { GGML_UNUSED(seq_id); GGML_UNUSED(p0); GGML_UNUSED(p1); // TODO: current hw doesn't support this feature;check if the intention is to remove the end of seq or to do shift if (p1 == -1) { kv_manager->RemoveTokensAtEnd(seq_id, seq_pos_max(seq_id) - p0 + 1); return true; } // if (p1 == -1) { //TODO: current hw-op doesn't support common-prefix // if (p0 == -1) { // kv_manager->Free(seq_id); // } else { // return false; // } // } // shift should be done by calling kv_manager.DoShift() return false; } void llama_kv_cache_calrt_adapter::seq_cp(llama_seq_id seq_id_src, llama_seq_id seq_id_dst, llama_pos p0, llama_pos p1) { GGML_UNUSED(seq_id_src); GGML_UNUSED(seq_id_dst); GGML_UNUSED(p0); GGML_UNUSED(p1); } void llama_kv_cache_calrt_adapter::seq_keep(llama_seq_id seq_id) { GGML_UNUSED(seq_id); } void llama_kv_cache_calrt_adapter::seq_add(llama_seq_id seq_id, llama_pos p0, llama_pos p1, llama_pos shift) { GGML_UNUSED(seq_id); GGML_UNUSED(p0); GGML_UNUSED(p1); GGML_UNUSED(shift); } void llama_kv_cache_calrt_adapter::seq_div(llama_seq_id seq_id, llama_pos p0, llama_pos p1, int d) { GGML_UNUSED(seq_id); GGML_UNUSED(p0); GGML_UNUSED(p1); GGML_UNUSED(d); } llama_pos llama_kv_cache_calrt_adapter::seq_pos_min(llama_seq_id seq_id) const { return kv_manager->seqPosMin(seq_id); } llama_pos llama_kv_cache_calrt_adapter::seq_pos_max(llama_seq_id seq_id) const { return kv_manager->seqPosMax(seq_id); } // state write/load void llama_kv_cache_calrt_adapter::state_write(llama_io_write_i & io, llama_seq_id seq_id, llama_state_seq_flags flags) const { GGML_UNUSED(io); GGML_UNUSED(seq_id); GGML_UNUSED(flags); } void llama_kv_cache_calrt_adapter::state_read(llama_io_read_i & io, llama_seq_id seq_id, llama_state_seq_flags flags) { GGML_UNUSED(io); GGML_UNUSED(seq_id); GGML_UNUSED(flags); } std::unique_ptr llama_kv_adapter_init(calrt::KvManager * kv) { if (kv == nullptr) { return nullptr; } return std::make_unique(kv); }