| 11 | #include <vector> |
| 12 | |
| 13 | static bool eval_tokens(struct llama_context * ctx_llama, std::vector<llama_token> tokens, int n_batch, int * n_past) { |
| 14 | int N = (int) tokens.size(); |
| 15 | for (int i = 0; i < N; i += n_batch) { |
| 16 | int n_eval = (int) tokens.size() - i; |
| 17 | if (n_eval > n_batch) { |
| 18 | n_eval = n_batch; |
| 19 | } |
| 20 | if (llama_decode(ctx_llama, llama_batch_get_one(&tokens[i], n_eval, *n_past, 0))) { |
| 21 | fprintf(stderr, "%s : failed to eval. token %d/%d (batch size %d, n_past %d)\n", __func__, i, N, n_batch, *n_past); |
| 22 | return false; |
| 23 | } |
| 24 | *n_past += n_eval; |
| 25 | } |
| 26 | return true; |
| 27 | } |
| 28 | |
| 29 | static bool eval_id(struct llama_context * ctx_llama, int id, int * n_past) { |
| 30 | std::vector<llama_token> tokens; |
no test coverage detected