MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / eval_tokens

Function eval_tokens

examples/llava/llava-cli.cpp:13–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include <vector>
12
13static 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
29static bool eval_id(struct llama_context * ctx_llama, int id, int * n_past) {
30 std::vector<llama_token> tokens;

Callers 2

eval_idFunction · 0.85
eval_stringFunction · 0.85

Calls 4

fprintfFunction · 0.85
llama_decodeFunction · 0.50
llama_batch_get_oneFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected