diff --git a/dpnp/backend/extensions/lapack/gesv.cpp b/dpnp/backend/extensions/lapack/gesv.cpp index 9c9c782692f6..30cf9b97304e 100644 --- a/dpnp/backend/extensions/lapack/gesv.cpp +++ b/dpnp/backend/extensions/lapack/gesv.cpp @@ -144,6 +144,16 @@ static sycl::event gesv_impl(sycl::queue &exec_q, is_exception_caught = true; gesv_utils::handle_lapack_exc(exec_q, lda, a, scratchpad_size, scratchpad, ipiv, e, error_msg); + } catch (oneapi::mkl::computation_error const &e) { + // TODO: remove this catch when gh-642(oneMath) is fixed + // Workaround for oneMath interfaces + // oneapi::mkl::computation_error is thrown instead of + // oneapi::mkl::lapack::computation_error. + if (scratchpad != nullptr) + sycl_free_noexcept(scratchpad, exec_q); + if (ipiv != nullptr) + sycl_free_noexcept(ipiv, exec_q); + throw LinAlgError("The input coefficient matrix is singular."); } catch (sycl::exception const &e) { is_exception_caught = true; error_msg << "Unexpected SYCL exception caught during getrf() or " diff --git a/dpnp/backend/extensions/lapack/getrf.cpp b/dpnp/backend/extensions/lapack/getrf.cpp index bbb5079a2232..204d682984ef 100644 --- a/dpnp/backend/extensions/lapack/getrf.cpp +++ b/dpnp/backend/extensions/lapack/getrf.cpp @@ -120,6 +120,15 @@ static sycl::event getrf_impl(sycl::queue &exec_q, "call:\nreason: " << e.what() << "\ninfo: " << e.info(); } + } catch (oneapi::mkl::computation_error const &e) { + // TODO: remove this catch when gh-642(oneMath) is fixed + // Workaround for oneMath interfaces + // oneapi::mkl::computation_error is thrown instead of + // oneapi::mkl::lapack::computation_error. + is_exception_caught = false; + // computation_error means the input matrix is singular + // dev_info must be set to any positive value. + dev_info[0] = 2; } catch (sycl::exception const &e) { is_exception_caught = true; error_msg << "Unexpected SYCL exception caught during getrf() call:\n"