Skip to content

Commit 8779dab

Browse files
vtavanaantonwolfy
andauthored
fix cholesky for 0-D array (#1584)
Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com>
1 parent 0fe9a00 commit 8779dab

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

dpnp/backend/kernels/dpnp_krnl_linalg.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ DPCTLSyclEventRef dpnp_cholesky_c(DPCTLSyclQueueRef q_ref,
4747
(void)dep_event_vec_ref;
4848

4949
DPCTLSyclEventRef event_ref = nullptr;
50+
if (!data_size) {
51+
return event_ref;
52+
}
5053
sycl::queue q = *(reinterpret_cast<sycl::queue *>(q_ref));
5154

5255
sycl::event event;

tests/test_linalg.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ def test_cholesky(array):
6060
assert_array_equal(expected, result)
6161

6262

63+
@pytest.mark.parametrize(
64+
"shape",
65+
[
66+
(0, 0),
67+
(3, 0, 0),
68+
],
69+
ids=[
70+
"(0, 0)",
71+
"(3, 0, 0)",
72+
],
73+
)
74+
def test_cholesky_0D(shape):
75+
a = numpy.empty(shape)
76+
ia = inp.array(a)
77+
result = inp.linalg.cholesky(ia)
78+
expected = numpy.linalg.cholesky(a)
79+
assert_array_equal(expected, result)
80+
81+
6382
@pytest.mark.parametrize(
6483
"arr",
6584
[[[1, 0, -1], [0, 1, 0], [1, 0, 1]], [[1, 2, 3], [4, 5, 6], [7, 8, 9]]],

0 commit comments

Comments
 (0)