| 251 | } |
| 252 | |
| 253 | void 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 | |
| 282 | llama_pos llama_kv_cache_unified::seq_pos_min(llama_seq_id seq_id) const { |
| 283 | return cells.seq_pos_min(seq_id); |