Skip to content

dpt.sum over axis for transposed input array #1391

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

Closed
antonwolfy opened this issue Sep 6, 2023 · 1 comment · Fixed by #1392
Closed

dpt.sum over axis for transposed input array #1391

antonwolfy opened this issue Sep 6, 2023 · 1 comment · Fixed by #1392
Labels
bug Something isn't working

Comments

@antonwolfy
Copy link
Collaborator

Due to merging gh-1364 the below example has been broken:

import numpy, dpctl, dpctl.tensor as dpt
from math import prod

sh = (1, 2, 3)
a = dpt.arange(prod(sh), dtype='i4')
a = dpt.reshape(a, sh)
aT = dpt.permute_dims(a, (2, 1, 0))

aT.shape
# Out: (3, 2, 1)

dpt.sum(aT, axis=2)
# Out:
# usm_ndarray([[0, 1],
#              [2, 3],
#              [4, 5]])

b = numpy.arange(prod(sh), dtype='i4').reshape(sh)
bT = b.T

bT.shape
# Out: (3, 2, 1)

bT.sum(axis=2)
# Out:
# array([[0, 3],
#        [1, 4],
#        [2, 5]])
@antonwolfy antonwolfy added the bug Something isn't working label Sep 6, 2023
@antonwolfy
Copy link
Collaborator Author

Similar issue with another shape:

sh = (3, 3, 3)
a = dpt.arange(prod(sh), dtype='i4')
a = dpt.reshape(a, sh)
aT = dpt.permute_dims(a, (2, 1, 0))

aT.strides
# Out: (1, 3, 9)

dpt.sum(aT, axis=2)
# Out:
# usm_ndarray([[27, 30, 33],
#              [36, 39, 42],
#              [45, 48, 51]])

b = numpy.arange(prod(sh), dtype='i4').reshape(sh)
bT = b.T

bT.strides
# Out: (4, 12, 36)

bT.sum(axis=2)
# Out:
# array([[27, 36, 45],
#        [30, 39, 48],
#        [33, 42, 51]])

oleksandr-pavlyk added a commit that referenced this issue Sep 6, 2023
The kernel is applicable if both inputs are F-contiguous, or
if the first input if F-contiguous and we are reducing to
1d C-contiguous array.

Closes gh-1391
oleksandr-pavlyk added a commit that referenced this issue Sep 6, 2023
oleksandr-pavlyk added a commit that referenced this issue Sep 6, 2023
The kernel is applicable if both inputs are F-contiguous, or
if the first input if F-contiguous and we are reducing to
1d C-contiguous array.

Closes gh-1391
oleksandr-pavlyk added a commit that referenced this issue Sep 6, 2023
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

Successfully merging a pull request may close this issue.

1 participant