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

Fix ravel for strides 0 #5978

Merged
merged 3 commits into from Nov 4, 2021
Merged

Fix ravel for strides 0 #5978

merged 3 commits into from Nov 4, 2021

Conversation

emcastillo
Copy link
Member

@emcastillo emcastillo commented Nov 1, 2021

Always enforce the copy if the array is neither c- or f-contiguous.

Closes #5972

Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we only have to call _core._internal_ascontiguousarray (after reshape) to fix the issue.

if order_char == b'A':
if self._f_contiguous and not self._c_contiguous:
order_char = b'F'
else:
order_char = b'C'
if order_char == b'C':
return _reshape(self, shape)
return _reshape(self, shape, enforce_copy)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input is copied only if it's required. Maybe it should have been tested that

>>> x = xp.ones((2, 3)); x.ravel().base is x
True

@emcastillo
Copy link
Member Author

yes, _core._internal_ascontiguousarray is much much better, thanks!!!

@emcastillo
Copy link
Member Author

emcastillo commented Nov 1, 2021

Review comments done!
thanks!

@emcastillo
Copy link
Member Author

seems like i rebased something that i shouldn't, will fix

@kmaehashi kmaehashi added cat:bug Bugs prio:high to-be-backported Pull-requests to be backported to stable branch labels Nov 2, 2021
@kmaehashi kmaehashi added this to the v10.0.0rc1 milestone Nov 2, 2021
@emcastillo
Copy link
Member Author

Should be ok now! PTAL :)

emcastillo and others added 2 commits November 4, 2021 11:16
Co-authored-by: Toshiki Kataoka <tos.lunar@gmail.com>
Co-authored-by: Toshiki Kataoka <tos.lunar@gmail.com>
@emcastillo
Copy link
Member Author

makes sense, thanks!!

Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@toslunar
Copy link
Member

toslunar commented Nov 4, 2021

pfnCI, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit 93cfba6, target branch master) succeeded!

@toslunar toslunar merged commit 967104d into cupy:master Nov 4, 2021
chainer-ci pushed a commit to chainer-ci/cupy that referenced this pull request Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:bug Bugs prio:high to-be-backported Pull-requests to be backported to stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ravel not working when stride is 0
4 participants