| 432 | } |
| 433 | |
| 434 | bool llama_context::kv_self_update() { |
| 435 | if (!memory) { |
| 436 | return false; |
| 437 | } |
| 438 | |
| 439 | llama_kv_cache * kv_self = static_cast<llama_kv_cache *>(memory.get()); |
| 440 | |
| 441 | if (!kv_self->update(*this)) { |
| 442 | // no updates have been performed |
| 443 | return false; |
| 444 | } |
| 445 | |
| 446 | // if the KV cache did any computation, we have to reserve a new worst-case graph |
| 447 | const auto kv_state = kv_self->init_full(); |
| 448 | if (!kv_state) { |
| 449 | throw std::runtime_error("failed to initialize KV cache"); |
| 450 | } |
| 451 | |
| 452 | const uint32_t n_seqs = cparams.n_seq_max; |
| 453 | const uint32_t n_tokens = std::min(cparams.n_ctx, cparams.n_ubatch); |
| 454 | |
| 455 | auto * gf = graph_reserve(n_tokens, n_seqs, n_tokens, kv_state.get()); |
| 456 | if (!gf) { |
| 457 | LLAMA_LOG_ERROR("%s: failed to reserve graph after the KV cache update\n", __func__); |
| 458 | } |
| 459 | |
| 460 | return true; |
| 461 | } |
| 462 | |
| 463 | enum llama_pooling_type llama_context::pooling_type() const { |
| 464 | return cparams.pooling_type; |
no test coverage detected