]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
ggml : fix ggml_clamp thresholds being read as ints instead of floats (#221)
authorGeorgi Gerganov <redacted>
Wed, 7 Jun 2023 16:14:50 +0000 (19:14 +0300)
committerGitHub <redacted>
Wed, 7 Jun 2023 16:14:50 +0000 (19:14 +0300)
src/ggml.c

index 18a2007b7bf40710d55310afc0a13b84c7503e90..f4150161a87c5a689b9164c5db22cac21e437b55 100644 (file)
@@ -6383,7 +6383,7 @@ struct ggml_tensor * ggml_clamp(
 
     ggml_scratch_save(ctx);
 
-    struct ggml_tensor * b = ggml_new_tensor_1d(ctx, GGML_TYPE_I32, 3);
+    struct ggml_tensor * b = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 3);
 
     ((float *) b->data)[0] = min;
     ((float *) b->data)[1] = max;
@@ -11139,8 +11139,8 @@ static void ggml_compute_forward_clamp_f32(
         return;
     }
 
-    const int min = ((float *) src1->data)[0];
-    const int max = ((float *) src1->data)[1];
+    const float min = ((float *) src1->data)[0];
+    const float max = ((float *) src1->data)[1];
 
     const int ith = params->ith;
     const int nth = params->nth;