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

Function check_context_size

smallthinker/tools/run/run.cpp:956–966  ·  view source on GitHub ↗

Check if we have enough space in the context to evaluate this batch

Source from the content-addressed store, hash-verified

954
955// Check if we have enough space in the context to evaluate this batch
956static 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
969static int convert_token_to_string(const llama_vocab * vocab, const llama_token token_id, std::string & piece) {

Callers 1

generateFunction · 0.85

Calls 5

printfFunction · 0.85
printeFunction · 0.85
llama_n_ctxFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected