| 1546 | } |
| 1547 | |
| 1548 | void common_batch_add( |
| 1549 | struct llama_batch & batch, |
| 1550 | llama_token id, |
| 1551 | llama_pos pos, |
| 1552 | const std::vector<llama_seq_id> & seq_ids, |
| 1553 | bool logits) { |
| 1554 | GGML_ASSERT(batch.seq_id[batch.n_tokens] && "llama_batch size exceeded"); |
| 1555 | |
| 1556 | batch.token [batch.n_tokens] = id; |
| 1557 | batch.pos [batch.n_tokens] = pos; |
| 1558 | batch.n_seq_id[batch.n_tokens] = seq_ids.size(); |
| 1559 | for (size_t i = 0; i < seq_ids.size(); ++i) { |
| 1560 | batch.seq_id[batch.n_tokens][i] = seq_ids[i]; |
| 1561 | } |
| 1562 | batch.logits [batch.n_tokens] = logits; |
| 1563 | |
| 1564 | batch.n_tokens++; |
| 1565 | } |
| 1566 | |
| 1567 | // |
| 1568 | // Vocab utils |