From adccc1dada6f8ba043467a1b2374543b1a512e7a Mon Sep 17 00:00:00 2001 From: slaren Date: Sun, 23 Jul 2023 01:23:43 +0200 Subject: [PATCH] alibi: use memcpy for float params --- ggml-metal.m | 3 ++- ggml.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ggml-metal.m b/ggml-metal.m index 2d9f4a657..4a9062ec1 100644 --- a/ggml-metal.m +++ b/ggml-metal.m @@ -844,7 +844,8 @@ void ggml_metal_graph_compute( const int n_past = ((int32_t *) dst->op_params)[0]; UNUSED(n_past); const int n_head = ((int32_t *) dst->op_params)[1]; - const float max_bias = ((float *) dst->op_params)[2]; + float max_bias; + memcpy(&max_bias, (int32_t *) dst->op_params + 2, sizeof(float)); if (__builtin_popcount(n_head) != 1) { GGML_ASSERT(false && "only power-of-two n_head implemented"); diff --git a/ggml.c b/ggml.c index ed53c43ed..c019ab3f6 100644 --- a/ggml.c +++ b/ggml.c @@ -11660,7 +11660,8 @@ static void ggml_compute_forward_alibi_f32( const int n_past = ((int32_t *) dst->op_params)[0]; const int n_head = ((int32_t *) dst->op_params)[1]; - const float max_bias = ((float *) dst->op_params)[2]; + float max_bias; + memcpy(&max_bias, (int32_t *) dst->op_params + 2, sizeof(float)); assert(n_past >= 0); @@ -11722,7 +11723,8 @@ static void ggml_compute_forward_alibi_f16( const int n_past = ((int32_t *) dst->op_params)[0]; const int n_head = ((int32_t *) dst->op_params)[1]; - const float max_bias = ((float *) dst->op_params)[2]; + float max_bias; + memcpy(&max_bias, (int32_t *) dst->op_params + 2, sizeof(float)); assert(n_past >= 0);