]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
vulkan : fix soft_max.comp division by zero (#2633)
authorgn64 <redacted>
Mon, 16 Dec 2024 10:34:38 +0000 (19:34 +0900)
committerGitHub <redacted>
Mon, 16 Dec 2024 10:34:38 +0000 (12:34 +0200)
This change prevents a division by zero error when p.KY is 0.

ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp

index 6e20b6411cadcf7931e848b406c9d14a011aca73..a25808e16568a63c0235f83052a194f9b8dd92bc 100644 (file)
@@ -32,7 +32,7 @@ shared FLOAT_TYPE vals[BLOCK_SIZE];
 void soft_max(uint num_iters) {
     const uint tid = gl_LocalInvocationID.x;
     const uint rowx = gl_WorkGroupID.z * 262144 + gl_WorkGroupID.y * 512 + gl_WorkGroupID.x;
-    const uint rowy = rowx % p.KY;
+    const uint rowy = (p.KY > 0) ? (rowx % p.KY) : 0;
 
     if (rowx >= p.nrows_x) {
         return;