Skip to content

Commit

Permalink
Merge pull request #168 from sony/fix/20190605_zero_div_in_cuda_block…
Browse files Browse the repository at this point in the history
…s_for_size_0

Fix cuda kernel block calculation for zero size.
  • Loading branch information
TakuyaNarihira authored Jul 1, 2019
2 parents e2e031e + 4a54845 commit 15c1e9a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/nbla/cuda/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 15c1e9a

Please sign in to comment.