Skip to content

Commit

Permalink
ggml: fix zero division in ‘dne’ calculation in CUDA COUNT_EQUAL oper…
Browse files Browse the repository at this point in the history
…ator when ‘ne’ is small (ggml-org#10213)
SongXiaoXi authored and arthw committed Nov 18, 2024
1 parent 26e073f commit c92611b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ggml/src/ggml-cuda/count-equal.cu
Original file line number Diff line number Diff line change
@@ -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));

0 comments on commit c92611b

Please sign in to comment.