From 8d7be2c9864e0f38f53c459b34e489f76b6142b4 Mon Sep 17 00:00:00 2001 From: Pierrick HYMBERT Date: Thu, 11 Apr 2024 13:05:45 +0200 Subject: [PATCH] ggml-debug: printing also the sum of each tensor --- examples/ggml-debug/ggml-debug.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/ggml-debug/ggml-debug.cpp b/examples/ggml-debug/ggml-debug.cpp index 43be46ef0..80b4e6ef2 100644 --- a/examples/ggml-debug/ggml-debug.cpp +++ b/examples/ggml-debug/ggml-debug.cpp @@ -30,6 +30,7 @@ static std::string ggml_ne_string(const ggml_tensor * t) { static void ggml_print_tensor(uint8_t * data, ggml_type type, const int64_t * ne, const size_t * nb, int64_t n) { size_t bs = ggml_blck_size(type); + float sum = 0; for (int64_t i3 = 0; i3 < ne[3]; i3++) { printf(" [\n"); for (int64_t i2 = 0; i2 < ne[2] && i2 < n; i2++) { @@ -53,6 +54,7 @@ static void ggml_print_tensor(uint8_t * data, ggml_type type, const int64_t * ne GGML_ASSERT(false); } printf("%8.4f", v); + sum += v; if (i0 < ne[0] - 1 && i0 < n - 1) printf(", "); } if (ne[0] > n) printf(", ..."); @@ -63,6 +65,7 @@ static void ggml_print_tensor(uint8_t * data, ggml_type type, const int64_t * ne } if (ne[2] > n) printf(" ...\n"); printf(" ]\n"); + printf(" sum = %f\n", sum); } }