Skip to content

Commit eaf4bd8

Browse files
authored
eval-callback : fix conversion to float (#7184)
1 parent befddd0 commit eaf4bd8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/eval-callback/eval-callback.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ static void ggml_print_tensor(uint8_t * data, ggml_type type, const int64_t * ne
5252
size_t i = i3 * nb[3] + i2 * nb[2] + i1 * nb[1] + i0 * nb[0];
5353
float v;
5454
if (type == GGML_TYPE_F16) {
55-
v = ggml_fp16_to_fp32(*(ggml_fp16_t *) data + i);
55+
v = ggml_fp16_to_fp32(*(ggml_fp16_t *) &data[i]);
5656
} else if (type == GGML_TYPE_F32) {
57-
v = *(float *) data + i;
57+
v = *(float *) &data[i];
5858
} else if (type == GGML_TYPE_I32) {
59-
v = (float) *(int32_t *) data + i;
59+
v = (float) *(int32_t *) &data[i];
6060
} else if (type == GGML_TYPE_I16) {
61-
v = (float) *(int16_t *) data + i;
61+
v = (float) *(int16_t *) &data[i];
6262
} else if (type == GGML_TYPE_I8) {
63-
v = (float) *(int8_t *) data + i;
63+
v = (float) *(int8_t *) &data[i];
6464
} else {
6565
GGML_ASSERT(false);
6666
}

0 commit comments

Comments
 (0)