use memcpy for op params

This commit is contained in:
Xuan Son Nguyen
2025-07-09 12:05:34 +02:00
parent 50c678f6da
commit 0d70ca81e8
3 changed files with 12 additions and 6 deletions

View File

@@ -2255,8 +2255,10 @@ static bool ggml_metal_encode_node(
{ {
GGML_ASSERT(ggml_is_contiguous(src0)); GGML_ASSERT(ggml_is_contiguous(src0));
float scale = ((const float *)(dst->op_params))[0]; float scale;
float bias = ((const float *)(dst->op_params))[1]; float bias;
memcpy(&scale, ((const int32_t *) dst->op_params) + 0, sizeof(float));
memcpy(&bias, ((const int32_t *) dst->op_params) + 1, sizeof(float));
int64_t n = ggml_nelements(dst); int64_t n = ggml_nelements(dst);

View File

@@ -5586,8 +5586,10 @@ static void ggml_cl_scale(ggml_backend_t backend, const ggml_tensor * src0, cons
ggml_backend_opencl_context *backend_ctx = (ggml_backend_opencl_context *)backend->context; ggml_backend_opencl_context *backend_ctx = (ggml_backend_opencl_context *)backend->context;
float scale = ((const float *)(dst->op_params))[0]; float scale;
float bias = ((const float *)(dst->op_params))[1]; float bias;
memcpy(&scale, ((int32_t *) dst->op_params) + 0, sizeof(float));
memcpy(&bias, ((int32_t *) dst->op_params) + 1, sizeof(float));
ggml_tensor_extra_cl * extra0 = (ggml_tensor_extra_cl *)src0->extra; ggml_tensor_extra_cl * extra0 = (ggml_tensor_extra_cl *)src0->extra;
ggml_tensor_extra_cl * extrad = (ggml_tensor_extra_cl *)dst->extra; ggml_tensor_extra_cl * extrad = (ggml_tensor_extra_cl *)dst->extra;

View File

@@ -2318,8 +2318,10 @@ inline void ggml_sycl_op_scale(ggml_backend_sycl_context & ctx, ggml_tensor * ds
const float * src0_dd = static_cast<const float *>(dst->src[0]->data); const float * src0_dd = static_cast<const float *>(dst->src[0]->data);
float * dst_dd = static_cast<float *>(dst->data); float * dst_dd = static_cast<float *>(dst->data);
float scale = ((const float *)(dst->op_params))[0]; float scale;
float bias = ((const float *)(dst->op_params))[1]; float bias;
memcpy(&scale, dst->op_params, sizeof(float));
memcpy(&bias, (float *) dst->op_params + 1, sizeof(float));
scale_f32_sycl(src0_dd, dst_dd, scale, bias, ggml_nelements(dst->src[0]), main_stream); scale_f32_sycl(src0_dd, dst_dd, scale, bias, ggml_nelements(dst->src[0]), main_stream);
/* /*