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

Method seq_div

smallthinker/src/llama-kv-cache-unified.cpp:253–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253void llama_kv_cache_unified::seq_div(llama_seq_id seq_id, llama_pos p0, llama_pos p1, int d) {
254 if (d == 1) {
255 return;
256 }
257
258 if (p0 < 0) {
259 p0 = 0;
260 }
261
262 if (p1 < 0) {
263 p1 = std::numeric_limits<llama_pos>::max();
264 }
265
266 // If there is no range then return early to avoid looping over the cache.
267 if (p0 == p1) {
268 return;
269 }
270
271 for (uint32_t i = 0; i < cells.size(); ++i) {
272 if (!cells.pos_in(i, p0, p1)) {
273 continue;
274 }
275
276 if (cells.seq_has(i, seq_id)) {
277 cells.pos_div(i, d);
278 }
279 }
280}
281
282llama_pos llama_kv_cache_unified::seq_pos_min(llama_seq_id seq_id) const {
283 return cells.seq_pos_min(seq_id);

Callers 1

llama_kv_self_seq_divFunction · 0.45

Calls 5

maxFunction · 0.85
pos_inMethod · 0.80
seq_hasMethod · 0.80
pos_divMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected