| 470 | } |
| 471 | |
| 472 | llama_ubatch llama_batch_allocr::split_simple(uint32_t n_ubatch) { |
| 473 | // find the first unused token |
| 474 | uint32_t cur_idx = 0; |
| 475 | while (cur_idx < used.size() && used[cur_idx]) { |
| 476 | ++cur_idx; |
| 477 | } |
| 478 | |
| 479 | // we are done |
| 480 | if (cur_idx >= used.size()) { |
| 481 | return {}; |
| 482 | } |
| 483 | |
| 484 | std::vector<int32_t> idxs; |
| 485 | |
| 486 | while (true) { |
| 487 | idxs.push_back(cur_idx); |
| 488 | |
| 489 | used[cur_idx] = true; |
| 490 | ++n_used; |
| 491 | |
| 492 | ++cur_idx; |
| 493 | |
| 494 | if (cur_idx >= used.size()) { |
| 495 | break; |
| 496 | } |
| 497 | |
| 498 | if (idxs.size() >= n_ubatch) { |
| 499 | break; |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | return ubatch_add(idxs, idxs.size(), false); |
| 504 | } |
| 505 | |
| 506 | llama_ubatch llama_batch_allocr::split_equal(uint32_t n_ubatch, bool sequential) { |
| 507 | if (sequential && has_cpl) { |
no test coverage detected