From cdbd6be420394ca8982d5bd884f28437f75a1484 Mon Sep 17 00:00:00 2001 From: Ivan Yashchuk Date: Tue, 20 Aug 2019 13:38:50 +0300 Subject: [PATCH] Added early return for empty arrays in cuda qr kernel --- chainerx_cc/chainerx/cuda/cuda_device/linalg.cu | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chainerx_cc/chainerx/cuda/cuda_device/linalg.cu b/chainerx_cc/chainerx/cuda/cuda_device/linalg.cu index e29ab6a7f2e6..f6937c75e9c9 100644 --- a/chainerx_cc/chainerx/cuda/cuda_device/linalg.cu +++ b/chainerx_cc/chainerx/cuda/cuda_device/linalg.cu @@ -337,6 +337,12 @@ void QrImpl(const Array& a, const Array& q, const Array& r, const Array& tau, Qr int64_t k = std::min(m, n); int64_t lda = std::max(int64_t{1}, m); + // Older versions of cuSOLVER (<10.1) might not work well with zero sized arrays + // therefore it's better to return earlier + if (a.shape().GetTotalSize() == 0 && mode != QrMode::kComplete) { + return; + } + // cuSOLVER does not return correct result in this case if (mode == QrMode::kComplete && n == 0) { device.backend().CallKernel(q);