]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
ggml: fix zero division in ‘dne’ calculation in CUDA COUNT_EQUAL operator when ‘ne...
authorSXX <redacted>
Sat, 9 Nov 2024 07:35:46 +0000 (15:35 +0800)
committerGeorgi Gerganov <redacted>
Fri, 15 Nov 2024 13:21:04 +0000 (15:21 +0200)
ggml/src/ggml-cuda/count-equal.cu

index ffb053b10181888bab45f828b65207f8364736eb..08898115daed25c6330a69101168e998d6074fdb 100644 (file)
@@ -44,7 +44,7 @@ void ggml_cuda_count_equal(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
 
     const int64_t ne = ggml_nelements(src0);
     GGML_ASSERT(ne < (1 << 30) && "atomicAdd implementation only supports int");
-    const int64_t dne = GGML_PAD(ne / (4*nsm), CUDA_COUNT_EQUAL_CHUNK_SIZE);
+    const int64_t dne = GGML_PAD((ne + 4*nsm - 1) / (4*nsm), CUDA_COUNT_EQUAL_CHUNK_SIZE);
 
     CUDA_CHECK(cudaMemsetAsync(dst_d, 0, ggml_nbytes(dst), stream));