Skip to content

dpnp.linalg.qr raises ValueError exception due to non-contagious input array passed to the LAPACK extension #2311

@antonwolfy

Description

@antonwolfy

The bellow examples caused unexpected ValueError exception raised:

import dpnp

dpnp.__version__
# Out: '0.17.0dev6+8.g0bda96adf39'

x = dpnp.array([[[0.], [0.]]])
dpnp.linalg.qr(x, mode='complete')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 1
----> 1 dpnp.linalg.qr(x, mode='complete')

File ~/dpnp/dpnp/linalg/dpnp_iface_linalg.py:1633, in qr(a, mode)
   1630 if mode not in ("reduced", "complete", "r", "raw"):
   1631     raise ValueError(f"Unrecognized mode {mode}")
-> 1633 return dpnp_qr(a, mode)

File ~/dpnp/dpnp/linalg/dpnp_utils_linalg.py:2463, in dpnp_qr(a, mode)
   2455 """
   2456 dpnp_qr(a, mode="reduced")
   2457
   2458 Return the qr factorization of `a` matrix.
   2459
   2460 """
   2462 if a.ndim > 2:
-> 2463     return _batched_qr(a, mode=mode)
   2465 a_usm_arr = dpnp.get_usm_ndarray(a)
   2466 a_sycl_queue = a.sycl_queue

File ~/dpnp/dpnp/linalg/dpnp_utils_linalg.py:485, in _batched_qr(a, mode)
    476 lapack_func = (
    477     "_ungqr_batch"
    478     if dpnp.issubdtype(res_type, dpnp.complexfloating)
    479     else "_orgqr_batch"
    480 )
    482 # Call the LAPACK extension function _orgqr_batch/ to generate the real
    483 # orthogonal/complex unitary matrices `Qi` of the QR factorization
    484 # for a batch of general matrices.
--> 485 ht_ev, lapack_ev = getattr(li, lapack_func)(
    486     a_sycl_queue,
    487     q.get_array(),
    488     tau_h.get_array(),
    489     m,
    490     mc,
    491     k,
    492     q_stride,
    493     tau_stride,
    494     batch_size,
    495     depends=[copy_ev],
    496 )
    497 _manager.add_event_pair(ht_ev, lapack_ev)
    499 q = q[..., :mc, :].swapaxes(-2, -1)

ValueError: The input array must be C-contiguous

x = dpnp.array([[0.], [0.]])
dpnp.linalg.qr(x, mode='complete')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[6], line 1
----> 1 dpnp.linalg.qr(x, mode='complete')

File ~/dpnp/dpnp/linalg/dpnp_iface_linalg.py:1633, in qr(a, mode)
   1630 if mode not in ("reduced", "complete", "r", "raw"):
   1631     raise ValueError(f"Unrecognized mode {mode}")
-> 1633 return dpnp_qr(a, mode)

File ~/dpnp/dpnp/linalg/dpnp_utils_linalg.py:2564, in dpnp_qr(a, mode)
   2556 lapack_func = (
   2557     "_ungqr"
   2558     if dpnp.issubdtype(res_type, dpnp.complexfloating)
   2559     else "_orgqr"
   2560 )
   2562 # Call the LAPACK extension function _orgqr/_ungqf to generate the real
   2563 # orthogonal/complex unitary matrix `Q` of the QR factorization
-> 2564 ht_ev, lapack_ev = getattr(li, lapack_func)(
   2565     a_sycl_queue,
   2566     m,
   2567     mc,
   2568     k,
   2569     q.get_array(),
   2570     tau_h.get_array(),
   2571     depends=[copy_ev],
   2572 )
   2573 _manager.add_event_pair(ht_ev, lapack_ev)
   2575 q = q[:mc].transpose()

ValueError: The input array must be C-contiguous

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions