diff --git a/common/unified/matrix/dense_kernels.template.cpp b/common/unified/matrix/dense_kernels.template.cpp index 05966ede9d3..9258fdf8a46 100644 --- a/common/unified/matrix/dense_kernels.template.cpp +++ b/common/unified/matrix/dense_kernels.template.cpp @@ -263,7 +263,7 @@ void compute_mean(std::shared_ptr exec, return x(i, j) * inv_total_size; }, GKO_KERNEL_REDUCE_SUM(ValueType), result->get_values(), x->get_size(), - tmp, x, ValueType_nc{1.} / x->get_size()[0]); + tmp, x, ValueType_nc{1.} / std::max(1ul, x->get_size()[0])); }