MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / seq_div

Method seq_div

subprojects/llama.cpp/src/llama-kv-cache.cpp:446–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444}
445
446void llama_kv_cache::seq_div(llama_seq_id seq_id, llama_pos p0, llama_pos p1, int d) {
447 GGML_ASSERT(seq_id >= 0 && (size_t) seq_id < seq_to_stream.size());
448 GGML_ASSERT(hparams.n_pos_per_embd() == 1 && "seq_div() is only supported for n_pos_per_embd() == 1");
449
450 auto & cells = v_cells[seq_to_stream[seq_id]];
451
452 if (d == 1) {
453 return;
454 }
455
456 if (p0 < 0) {
457 p0 = 0;
458 }
459
460 if (p1 < 0) {
461 p1 = std::numeric_limits<llama_pos>::max();
462 }
463
464 // If there is no range then return early to avoid looping over the cache.
465 if (p0 == p1) {
466 return;
467 }
468
469 for (uint32_t i = 0; i < cells.size(); ++i) {
470 if (!cells.pos_in(i, p0, p1)) {
471 continue;
472 }
473
474 if (cells.seq_has(i, seq_id)) {
475 cells.pos_div(i, d);
476 }
477 }
478}
479
480llama_pos llama_kv_cache::seq_pos_min(llama_seq_id seq_id) const {
481 GGML_ASSERT(seq_id >= 0 && (size_t) seq_id < seq_to_stream.size());

Callers 1

llama_memory_seq_divFunction · 0.45

Calls 6

maxFunction · 0.85
n_pos_per_embdMethod · 0.80
pos_inMethod · 0.80
seq_hasMethod · 0.80
pos_divMethod · 0.80
sizeMethod · 0.65

Tested by

no test coverage detected