Skip to content

Commit 36b4f7e

Browse files
authored
llama : print timings on ctrl+c exit (#1021)
* print timings on ctrl+c exit * remove redundant free memory call. * add global pointer to ctx.
1 parent 10f19c1 commit 36b4f7e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/main/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#endif
2626

2727
static console_state con_st;
28+
static llama_context ** g_ctx;
2829

2930
static bool is_interacting = false;
3031

@@ -36,6 +37,7 @@ void sigint_handler(int signo) {
3637
if (!is_interacting) {
3738
is_interacting=true;
3839
} else {
40+
llama_print_timings(*g_ctx);
3941
_exit(130);
4042
}
4143
}
@@ -92,8 +94,9 @@ int main(int argc, char ** argv) {
9294

9395
// params.prompt = R"(// this function checks if the number n is prime
9496
//bool is_prime(int n) {)";
95-
97+
9698
llama_context * ctx;
99+
g_ctx = &ctx;
97100

98101
// load the model
99102
{

0 commit comments

Comments
 (0)