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

empty_like ignores memory-order #66

Open
untom opened this issue Mar 15, 2015 · 1 comment
Open

empty_like ignores memory-order #66

untom opened this issue Mar 15, 2015 · 1 comment

Comments

@untom
Copy link
Contributor

untom commented Mar 15, 2015

Consider:

x = np.random.normal(size=(3, 5)).astype(np.float64, order="F")
x_gpu = gpuarray.to_gpu(x)
y_gpu = gpuarray.empty_like(x_gpu)
x_gpu.flags.c_contiguous == y_gpu.flags.c_contiguous   # gives "False"

I'm not very familiar with the ArrayFlags mechanism. It seems to me that the problem is that empty_like doesn't set the strides argument of the GPUArray-constructor. But I don't know the repercussions of doing this, so I didn't send a PR.

@inducer
Copy link
Owner

inducer commented Mar 20, 2015

Matching the original strides is not a plausible strategy, since the argument array could be non-contiguous or have negative strides, neither of which would go well in a newly-allocated buffer that matches the argument's shape. Numpy's strategy seems to be to look at the original strides and see if they are more Fortran-like or C-like (increasing or decreasing) and appears to assign strides based on that.

I'd be happy to take a patch that implements a strategy like this. Bonus points if it matches numpy exactly.

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

2 participants