| 356 | } |
| 357 | |
| 358 | llama_memory_state_ptr llama_kv_cache_recurrent::init_batch(const llama_batch & batch, uint32_t n_ubatch, bool embd_pooled, bool logits_all) { |
| 359 | GGML_UNUSED(embd_pooled); |
| 360 | |
| 361 | auto sbatch = llama_sbatch(batch, hparams.n_embd, false, logits_all); |
| 362 | |
| 363 | std::vector<llama_ubatch> ubatches; |
| 364 | |
| 365 | while (sbatch.n_tokens > 0) { |
| 366 | llama_ubatch ubatch; |
| 367 | |
| 368 | if (embd_pooled) { |
| 369 | // Pooled embeddings cannot be split across ubatches (yet) |
| 370 | ubatch = sbatch.split_seq(n_ubatch); |
| 371 | } else { |
| 372 | ubatch = sbatch.split_equal(n_ubatch); |
| 373 | } |
| 374 | |
| 375 | ubatches.push_back(ubatch); |
| 376 | } |
| 377 | |
| 378 | if (!prepare(ubatches)) { |
| 379 | return std::make_unique<llama_kv_cache_recurrent_state>(LLAMA_MEMORY_STATUS_FAILED_PREPARE); |
| 380 | } |
| 381 | |
| 382 | return std::make_unique<llama_kv_cache_recurrent_state>(LLAMA_MEMORY_STATUS_SUCCESS, this, std::move(sbatch), std::move(ubatches)); |
| 383 | } |
| 384 | |
| 385 | llama_memory_state_ptr llama_kv_cache_recurrent::init_full() { |
| 386 | return std::make_unique<llama_kv_cache_recurrent_state>(LLAMA_MEMORY_STATUS_SUCCESS, this); |
nothing calls this directly
no test coverage detected