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

dpt.reshape changes strides of input array when reshaping to the same shape #1664

Closed
antonwolfy opened this issue May 6, 2024 · 0 comments · Fixed by #1677
Closed

dpt.reshape changes strides of input array when reshaping to the same shape #1664

antonwolfy opened this issue May 6, 2024 · 0 comments · Fixed by #1677

Comments

@antonwolfy
Copy link
Collaborator

The below example demonstrates different behavior in reshape method of NumPy and dpctl:

import numpy, dpctl, dpctl.tensor as dpt

dpctl.__version__
# Out: '0.17.0dev0+325.g0cb2181547'

a = dpt.ones((2, 1))
a.shape, a.strides
# Out: ((2, 1), (1, 1))

b = dpt.reshape(a, (2, 1))
b.shape, b.strides
# Out: ((2, 1), (1, 0))    # the output strides are changed

a = numpy.ones((2, 1)
a.shape, a.strides
# Out: ((2, 1), (8, 8))

b = numpy.reshape(a, (2, 1))
b.shape, b.strides
# Out: ((2, 1), (8, 8))    # the output strides are the same as for input array "a"

So, the question here if it's expected that the strides of output array might be changed when reshaping to the same shape?

oleksandr-pavlyk added a commit that referenced this issue May 15, 2024
Closes gh-1664

If copy is not required, and requested shape is the same
as the shape of the array, return the array itself.
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

Successfully merging a pull request may close this issue.

1 participant