Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dpnp.linalg.pinv( dpnp.zeros((2,1,1), dtype="f4")) raises ValueError unexpectedly #1843

Closed
oleksandr-pavlyk opened this issue May 21, 2024 · 2 comments
Assignees

Comments

@oleksandr-pavlyk
Copy link
Contributor

In [6]: import dpnp

In [7]: dpnp.linalg.pinv(dpnp.zeros((2,1,1), dtype="f4"))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

<< elided >>

ValueError: Can not reshape into [2, 1, 1]
@oleksandr-pavlyk
Copy link
Contributor Author

The test is discovered by array-api-tests

@antonwolfy
Copy link
Contributor

antonwolfy commented May 21, 2024

It looks the issue is somewhere in dpnp.matmul:

import dpnp

a = dpnp.ones((2, 1, 1))
a @ a

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 a @ a

File ~/code/dpnp/dpnp/dpnp_array.py:364, in dpnp_array.__matmul__(self, other)
    362 def __matmul__(self, other):
    363     """Return ``self@value``."""
--> 364     return dpnp.matmul(self, other)

File ~/code/dpnp/dpnp/dpnp_iface_linearalgebra.py:842, in matmul(x1, x2, out, casting, order, dtype, subok, signature, extobj, axes, axis)
    840
--> 842 return dpnp_matmul(
    843     x1,
    844     x2,
    845     out=out,
    846     casting=casting,
    847     order=order,
    848     dtype=dtype,
    849     axes=axes,
    850 )

File ~/code/dpnp/dpnp/dpnp_utils/dpnp_utils_linearalgebra.py:2215, in dpnp_matmul(x1, x2, out, casting, order, dtype, axes)
   2212     result = dpnp.tile(res, out.shape)
   2213 else:
   2214     result = (
-> 2215         dpnp.reshape(res, result_shape)
   2216         if res_shape != result_shape
   2217         else res
   2218     )
   2220 if compute_dtype != res_dtype:
   2221     result = dpnp.astype(result, res_dtype, copy=False)

File ~/code/dpnp/dpnp/dpnp_iface_manipulation.py:1373, in reshape(a, newshape, order, copy)
   1370     raise ValueError(f"order must be one of 'C' or 'F' (got {order})")
   1372 usm_arr = dpnp.get_usm_ndarray(a)
-> 1373 usm_arr = dpt.reshape(usm_arr, shape=newshape, order=order, copy=copy)
   1374 return dpnp_array._create_from_usm_ndarray(usm_arr)

File ~/miniconda3/envs/dpnp_dev/lib/python3.9/site-packages/dpctl/tensor/_reshape.py:146, in reshape(X, shape, order, copy)
    144     shape = [v if d == -1 else d for d in shape]
    145 if X.size != np.prod(shape):
--> 146     raise ValueError(f"Can not reshape into {shape}")
    147 if X.size:
    148     newsts = reshaped_strides(X.shape, X.strides, shape, order=order)

ValueError: Can not reshape into [2, 1, 1]

vtavana added a commit that referenced this issue May 22, 2024
vtavana added a commit that referenced this issue May 22, 2024
@vtavana vtavana mentioned this issue May 22, 2024
6 tasks
github-actions bot added a commit that referenced this issue May 22, 2024
github-actions bot added a commit that referenced this issue May 22, 2024
antonwolfy added a commit that referenced this issue May 22, 2024
Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com>
github-actions bot added a commit that referenced this issue May 22, 2024
Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com> 069cad2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants