alibi: use memcpy for float params

This commit is contained in:
slaren 2023-07-23 01:23:43 +02:00
parent f7e9d2785e
commit adccc1dada
2 changed files with 6 additions and 3 deletions

View file

@ -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");

6
ggml.c
View file

@ -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);