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

incorrect result from dpnp.matmul when out keyword is f_contiguous #1871

Closed
vtavana opened this issue Jun 7, 2024 · 0 comments
Closed

incorrect result from dpnp.matmul when out keyword is f_contiguous #1871

vtavana opened this issue Jun 7, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@vtavana
Copy link
Collaborator

vtavana commented Jun 7, 2024

dpnp.matmul returns the data in the result array in an incorrect order when out keyword is given and it is f_contiguous.
For instance,

>>> import dpnp
>>> a=dpnp.arange(4.).reshape(2,2)
>>> b=dpnp.array(a, order="C")
>>> out = dpnp.empty((2,2), order="F")
>>> dpnp.matmul(b,b, out=out)
# array([[ 2.,  6.],
#       [ 3., 11.]], dtype=float32)

>>>   out.flags
# C_CONTIGUOUS : False
# F_CONTIGUOUS : True

>>> import numpy
>>> a=numpy.arange(4.).reshape(2,2)
>>> b=numpy.array(a, order="C")
>>> out = numpy.empty((2,2), order="F")
>>> numpy.matmul(b,b, out=out)
# array([[ 2.,  3.],
#        [ 6., 11.]])

>>>   out.flags
# C_CONTIGUOUS : False
# F_CONTIGUOUS : True

Or for higher dimensions:

>>> import dpnp
>>> a=dpnp.arange(8.).reshape(2,2,2)
>>> b=a.transpose(0, 2, 1)
>>> out = dpnp.empty((2,2,2))
>>> out=out.transpose(0, 2, 1)
>>> dpnp.matmul(b,b, out=out)
# array([[[ 2.,  3.],
#        [ 6., 11.]],
#       [[46., 55.],
#        [66., 79.]]], dtype=float32)

>>> import numpy
>>> a=numpy.arange(8.).reshape(2,2,2)
>>> b=a.transpose(0, 2, 1)
>>> out = numpy.empty((2,2,2))
>>> out=out.transpose(0, 2, 1)
>>> numpy.matmul(b,b, out=out)
# array([[[ 2.,  6.],
#        [ 3., 11.]],
#       [[46., 66.],
#        [55., 79.]]])
@vtavana vtavana self-assigned this Jun 7, 2024
@vtavana vtavana added the bug Something isn't working label Jun 7, 2024
@vtavana vtavana mentioned this issue Jun 7, 2024
6 tasks
github-actions bot added a commit that referenced this issue Jun 7, 2024
github-actions bot added a commit that referenced this issue Jun 10, 2024
github-actions bot added a commit that referenced this issue Jun 10, 2024
github-actions bot added a commit that referenced this issue Jun 11, 2024
github-actions bot added a commit that referenced this issue Jun 14, 2024
github-actions bot added a commit that referenced this issue Jun 15, 2024
* update returned result when out is defined with order F

* address comments

* add test for out keyword in einsum

---------

Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com> fe93c05
vtavana added a commit that referenced this issue Jun 16, 2024
* update returned result when out is defined with order F

* address comments

* add test for out keyword in einsum

---------

Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant