Skip to content

Commit 89cb658

Browse files
Fix issue gh-2311 (#2314)
This PR suggests a solving #2311 When the input array is `(n, m)` or `(batch_size, n, m)` where m=1 `geqrf`/`geqrf_batch` call returns F-contig result array and `dpnp.empty_like()` is used to allocate `q` allocates F-contig array and this raises `ValueError` exception in `orgqr` and `ungqr` functions. Added `q` allocation always C-contig and updated tests
1 parent b6cc5fe commit 89cb658

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

dpnp/linalg/dpnp_utils_linalg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,15 @@ def _batched_qr(a, mode="reduced"):
449449
a_t,
450450
shape=(batch_size, m, m),
451451
dtype=res_type,
452+
order="C",
452453
)
453454
else:
454455
mc = k
455456
q = dpnp.empty_like(
456457
a_t,
457458
shape=(batch_size, n, m),
458459
dtype=res_type,
460+
order="C",
459461
)
460462

461463
# use DPCTL tensor function to fill the matrix array `q[..., :n, :]`
@@ -2532,13 +2534,15 @@ def dpnp_qr(a, mode="reduced"):
25322534
a_t,
25332535
shape=(m, m),
25342536
dtype=res_type,
2537+
order="C",
25352538
)
25362539
else:
25372540
mc = k
25382541
q = dpnp.empty_like(
25392542
a_t,
25402543
shape=(n, m),
25412544
dtype=res_type,
2545+
order="C",
25422546
)
25432547

25442548
# use DPCTL tensor function to fill the matrix array `q[:n]`

dpnp/tests/test_linalg.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,12 +2372,24 @@ class TestQr:
23722372
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
23732373
@pytest.mark.parametrize(
23742374
"shape",
2375-
[(2, 2), (3, 4), (5, 3), (16, 16), (2, 2, 2), (2, 4, 2), (2, 2, 4)],
2375+
[
2376+
(2, 1),
2377+
(2, 2),
2378+
(3, 4),
2379+
(5, 3),
2380+
(16, 16),
2381+
(3, 3, 1),
2382+
(2, 2, 2),
2383+
(2, 4, 2),
2384+
(2, 2, 4),
2385+
],
23762386
ids=[
2387+
"(2, 1)",
23772388
"(2, 2)",
23782389
"(3, 4)",
23792390
"(5, 3)",
23802391
"(16, 16)",
2392+
"(3, 3, 1)",
23812393
"(2, 2, 2)",
23822394
"(2, 4, 2)",
23832395
"(2, 2, 4)",

0 commit comments

Comments
 (0)