Check if we have enough space in the context to evaluate this batch
| 954 | |
| 955 | // Check if we have enough space in the context to evaluate this batch |
| 956 | static int check_context_size(const llama_context_ptr & ctx, const llama_batch & batch) { |
| 957 | const int n_ctx = llama_n_ctx(ctx.get()); |
| 958 | const int n_ctx_used = llama_kv_self_seq_pos_max(ctx.get(), 0); |
| 959 | if (n_ctx_used + batch.n_tokens > n_ctx) { |
| 960 | printf(LOG_COL_DEFAULT "\n"); |
| 961 | printe("context size exceeded\n"); |
| 962 | return 1; |
| 963 | } |
| 964 | |
| 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | // convert the token to a string |
| 969 | static int convert_token_to_string(const llama_vocab * vocab, const llama_token token_id, std::string & piece) { |
no test coverage detected