gn64 commited on
Commit
1ce577d
·
unverified ·
1 Parent(s): ad1017f

vulkan : fix soft_max.comp division by zero (#2633)

Browse files

This change prevents a division by zero error when p.KY is 0.

ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp CHANGED
@@ -32,7 +32,7 @@ shared FLOAT_TYPE vals[BLOCK_SIZE];
32
  void soft_max(uint num_iters) {
33
  const uint tid = gl_LocalInvocationID.x;
34
  const uint rowx = gl_WorkGroupID.z * 262144 + gl_WorkGroupID.y * 512 + gl_WorkGroupID.x;
35
- const uint rowy = rowx % p.KY;
36
 
37
  if (rowx >= p.nrows_x) {
38
  return;
 
32
  void soft_max(uint num_iters) {
33
  const uint tid = gl_LocalInvocationID.x;
34
  const uint rowx = gl_WorkGroupID.z * 262144 + gl_WorkGroupID.y * 512 + gl_WorkGroupID.x;
35
+ const uint rowy = (p.KY > 0) ? (rowx % p.KY) : 0;
36
 
37
  if (rowx >= p.nrows_x) {
38
  return;