add global pointer to ctx.

This commit is contained in:
wbpxre150 2023-04-22 10:57:56 +08:00
parent 391c5a247a
commit 1609357e6b

View file

@ -25,7 +25,7 @@
#endif #endif
static console_state con_st; static console_state con_st;
llama_context * ctx; static llama_context ** g_ctx;
static bool is_interacting = false; static bool is_interacting = false;
@ -37,7 +37,7 @@ void sigint_handler(int signo) {
if (!is_interacting) { if (!is_interacting) {
is_interacting=true; is_interacting=true;
} else { } else {
llama_print_timings(ctx); llama_print_timings(*g_ctx);
_exit(130); _exit(130);
} }
} }
@ -94,6 +94,9 @@ int main(int argc, char ** argv) {
// params.prompt = R"(// this function checks if the number n is prime // params.prompt = R"(// this function checks if the number n is prime
//bool is_prime(int n) {)"; //bool is_prime(int n) {)";
llama_context * ctx;
g_ctx = &ctx;
// load the model // load the model
{ {