From eaf4bd8b399a6ed4b834f91d22409d2a05c4d266 Mon Sep 17 00:00:00 2001 From: slaren Date: Fri, 10 May 2024 01:04:12 +0200 Subject: [PATCH] eval-callback : fix conversion to float (#7184) --- examples/eval-callback/eval-callback.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/eval-callback/eval-callback.cpp b/examples/eval-callback/eval-callback.cpp index 29b5f3b3c..e670d3769 100644 --- a/examples/eval-callback/eval-callback.cpp +++ b/examples/eval-callback/eval-callback.cpp @@ -52,15 +52,15 @@ static void ggml_print_tensor(uint8_t * data, ggml_type type, const int64_t * ne size_t i = i3 * nb[3] + i2 * nb[2] + i1 * nb[1] + i0 * nb[0]; float v; if (type == GGML_TYPE_F16) { - v = ggml_fp16_to_fp32(*(ggml_fp16_t *) data + i); + v = ggml_fp16_to_fp32(*(ggml_fp16_t *) &data[i]); } else if (type == GGML_TYPE_F32) { - v = *(float *) data + i; + v = *(float *) &data[i]; } else if (type == GGML_TYPE_I32) { - v = (float) *(int32_t *) data + i; + v = (float) *(int32_t *) &data[i]; } else if (type == GGML_TYPE_I16) { - v = (float) *(int16_t *) data + i; + v = (float) *(int16_t *) &data[i]; } else if (type == GGML_TYPE_I8) { - v = (float) *(int8_t *) data + i; + v = (float) *(int8_t *) &data[i]; } else { GGML_ASSERT(false); }