MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / llama_kv_cache_seq_rm

Function llama_kv_cache_seq_rm

llama.cpp:1753–1781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1751}
1752
1753static void llama_kv_cache_seq_rm(
1754 struct llama_kv_cache & cache,
1755 llama_seq_id seq_id,
1756 llama_pos p0,
1757 llama_pos p1) {
1758 uint32_t new_head = cache.size;
1759
1760 if (p0 < 0) p0 = 0;
1761 if (p1 < 0) p1 = std::numeric_limits<llama_pos>::max();
1762
1763 for (uint32_t i = 0; i < cache.size; ++i) {
1764 if (cache.cells[i].pos >= p0 && cache.cells[i].pos < p1) {
1765 if (seq_id < 0) {
1766 cache.cells[i].seq_id.clear();
1767 } else if (cache.cells[i].has_seq_id(seq_id)) {
1768 cache.cells[i].seq_id.erase(seq_id);
1769 } else {
1770 continue;
1771 }
1772 if (cache.cells[i].seq_id.empty()) {
1773 cache.cells[i].pos = -1;
1774 if (new_head == cache.size) new_head = i;
1775 }
1776 }
1777 }
1778
1779 // If we freed up a slot, set head to it so searching can start there.
1780 if (new_head != cache.size) cache.head = new_head;
1781}
1782
1783static void llama_kv_cache_seq_cp(
1784 struct llama_kv_cache & cache,

Callers 7

llama_evalFunction · 0.85
llama_eval_embdFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
update_slotsMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

maxFunction · 0.85
clearMethod · 0.45
has_seq_idMethod · 0.45
emptyMethod · 0.45

Tested by 1

mainFunction · 0.68