From 582bddc37a526b261bcc6128b4b8221391fa1c73 Mon Sep 17 00:00:00 2001 From: John <78893154+cmp-nct@users.noreply.github.com> Date: Tue, 23 Jan 2024 01:45:27 +0100 Subject: [PATCH] changed formating to adaptive exponential format --- ggml-backend.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ggml-backend.c b/ggml-backend.c index 3ab7970f4..81d16d96b 100644 --- a/ggml-backend.c +++ b/ggml-backend.c @@ -1746,8 +1746,7 @@ void ggml_printTensorSample(const char *prefix, const struct ggml_tensor * tenso } const char *sep = "+-------------------------------------------------------------------------------------------+\n"; - //printf("%s| Content of %s \"%s\" (%d dim)\n", sep, prefix, tensor->name, ggml_n_dims(tensor)); - + const int MAX_ELEMENTS_ROW = 10; const int MAX_ELEMENTS_COL = 6; const int MAX_ELEMENTS_LAYER = 3; // layered @@ -1765,7 +1764,7 @@ void ggml_printTensorSample(const char *prefix, const struct ggml_tensor * tenso if (n_dims == 1) { printf("| 1: "); for(int i = 0; i < tensor->ne[0] && i < MAX_ELEMENTS_ROW; i++){ - printf("%-7.4f, ", *(double *)((char *) tensor_data + i*tensor->nb[0])); + printf("%11.3g, ", *(double *)((char *) tensor_data + i*tensor->nb[0])); } if(MAX_ELEMENTS_ROW < tensor->ne[0]) printf(", .."); printf("\n%s", sep); @@ -1774,7 +1773,7 @@ void ggml_printTensorSample(const char *prefix, const struct ggml_tensor * tenso for(int i = 0; i < tensor->ne[0] && i < MAX_ELEMENTS_ROW; i++){ printf("| %d: ", i+1); for(int j = 0; j < tensor->ne[1] && j < MAX_ELEMENTS_COL; j++){ - printf("%-7.4f ", *(double *)((char *) tensor_data + i*tensor->nb[0] + j*tensor->nb[1])); + printf("%11.4g ", *(double *)((char *) tensor_data + i*tensor->nb[0] + j*tensor->nb[1])); if(j == MAX_ELEMENTS_COL - 1 && tensor->ne[1] > MAX_ELEMENTS_COL) printf(", .."); } printf("\n"); @@ -1787,7 +1786,7 @@ void ggml_printTensorSample(const char *prefix, const struct ggml_tensor * tenso for(int j = 0; j < tensor->ne[1] && j < MAX_ELEMENTS_COL; j++){ printf("["); for(int k = 0; k < tensor->ne[2] && k < MAX_ELEMENTS_LAYER; k++){ - printf("%-7.4f", *(double *)((char *) tensor_data + i*tensor->nb[0] + j*tensor->nb[1] + k*tensor->nb[2])); + printf("%11.4g", *(double *)((char *) tensor_data + i*tensor->nb[0] + j*tensor->nb[1] + k*tensor->nb[2])); if(k < tensor->ne[2] - 1 && k < MAX_ELEMENTS_LAYER - 1) printf(", "); } @@ -1806,7 +1805,7 @@ void ggml_printTensorSample(const char *prefix, const struct ggml_tensor * tenso for(int j = 0; j < tensor->ne[2] && j < MAX_ELEMENTS_COL; j++){ printf("["); for(int k = 0; k < tensor->ne[3] && k < MAX_ELEMENTS_LAYER; k++){ - printf("%-7.4f", *(double *)((char *) tensor_data + batch*tensor->nb[0] + i*tensor->nb[1] + j*tensor->nb[2] + k*tensor->nb[3])); + printf("%11.4f", *(double *)((char *) tensor_data + batch*tensor->nb[0] + i*tensor->nb[1] + j*tensor->nb[2] + k*tensor->nb[3])); if(k < tensor->ne[3] - 1 && k < MAX_ELEMENTS_LAYER - 1) printf(", "); }