From 0639ff16d092f3f63c2c393a17b261190dbf1574 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 12 Oct 2024 22:47:27 +0200 Subject: [PATCH] free batch before return --- examples/imatrix/imatrix.cpp | 1 + examples/perplexity/perplexity.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/examples/imatrix/imatrix.cpp b/examples/imatrix/imatrix.cpp index 8a0b425d8..1e97d2980 100644 --- a/examples/imatrix/imatrix.cpp +++ b/examples/imatrix/imatrix.cpp @@ -518,6 +518,7 @@ static bool compute_imatrix(llama_context * ctx, const common_params & params) { if (llama_decode(ctx, batch)) { LOG_ERR("%s : failed to eval\n", __func__); + llama_batch_free(batch); return false; } diff --git a/examples/perplexity/perplexity.cpp b/examples/perplexity/perplexity.cpp index 57d6fd1b2..181a3c86d 100644 --- a/examples/perplexity/perplexity.cpp +++ b/examples/perplexity/perplexity.cpp @@ -423,6 +423,7 @@ static results_perplexity perplexity_v2(llama_context * ctx, const common_params //LOG_DBG(" Batch %d: starts at %d, size is %d, n_past is %d\n",j,batch_start,batch_size,j * n_batch); if (llama_decode(ctx, batch)) { //LOG_ERR("%s : failed to eval\n", __func__); + llama_batch_free(batch); return {tokens, -1, logit_history, prob_history}; } @@ -1821,6 +1822,7 @@ static void kl_divergence(llama_context * ctx, const common_params & params) { if (llama_decode(ctx, batch)) { LOG_ERR("%s : failed to eval\n", __func__); + llama_batch_free(batch); return; }