From c5959d53ffa1ce52c69ec983ad40a570af559551 Mon Sep 17 00:00:00 2001 From: Iwan Kawrakow Date: Thu, 1 Jun 2023 14:07:42 +0300 Subject: [PATCH] Don't print zeros/NaNs when no count histogram has been collected --- llama.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/llama.cpp b/llama.cpp index f351844aa..c8e659f24 100644 --- a/llama.cpp +++ b/llama.cpp @@ -2248,12 +2248,16 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s } printf("size = %8.2f MB -> %8.2f MB | hist: ", tensor.size/1024.0/1024.0, new_size/1024.0/1024.0); + int64_t tot_count = 0; for (size_t i = 0; i < hist_cur.size(); i++) { hist_all[i] += hist_cur[i]; + tot_count += hist_cur[i]; } - for (size_t i = 0; i < hist_cur.size(); i++) { - printf("%5.3f ", hist_cur[i] / float(nelements)); + if (tot_count > 0) { + for (size_t i = 0; i < hist_cur.size(); i++) { + printf("%5.3f ", hist_cur[i] / float(nelements)); + } } printf("\n"); } @@ -2271,11 +2275,13 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s sum_all += hist_all[i]; } - printf("%s: hist: ", __func__); - for (size_t i = 0; i < hist_all.size(); i++) { - printf("%5.3f ", hist_all[i] / float(sum_all)); + if (sum_all > 0) { + printf("%s: hist: ", __func__); + for (size_t i = 0; i < hist_all.size(); i++) { + printf("%5.3f ", hist_all[i] / float(sum_all)); + } + printf("\n"); } - printf("\n"); } }