From 4a54845678cb2a4e7bf28e573bcdb20b8e228342 Mon Sep 17 00:00:00 2001 From: Stephen Tiedemann Date: Wed, 12 Jun 2019 11:04:48 +0200 Subject: [PATCH] Fix cuda kernel block calculation for zero size. --- include/nbla/cuda/common.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/nbla/cuda/common.hpp b/include/nbla/cuda/common.hpp index 8a5e3c0c1..8b34e7949 100644 --- a/include/nbla/cuda/common.hpp +++ b/include/nbla/cuda/common.hpp @@ -180,6 +180,8 @@ enum { The kernel is assumed to contain a grid-strided loop. */ inline int cuda_get_blocks_by_size(int size) { + if (size == 0) + return 0; const int blocks = NBLA_CUDA_GET_BLOCKS(size); const int inkernel_loop = NBLA_CEIL_INT_DIV(blocks, NBLA_CUDA_MAX_BLOCKS); const int total_blocks = NBLA_CEIL_INT_DIV(blocks, inkernel_loop);