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

mean fails with views #478

Open
cossio opened this issue Jun 13, 2023 · 1 comment
Open

mean fails with views #478

cossio opened this issue Jun 13, 2023 · 1 comment
Labels

Comments

@cossio
Copy link

cossio commented Jun 13, 2023

A = gpu(rand(3, 5, 2))
mean(@views A[1, :, :]; dims=2)
# ERROR: Scalar indexing is disallowed.

However, the following all work:

sum(@views A[1, :, :]; dims=2)
mean(A[1, :, :]; dims=2)
sum(A[1, :, :]; dims=2)
@cossio cossio added the bug label Jun 13, 2023
@maleadt maleadt transferred this issue from JuliaGPU/CUDA.jl Jun 13, 2023
@maleadt
Copy link
Member

maleadt commented Jun 13, 2023

As I commented on Slack:

that view is not contiguous, so it results in a SubArray object instead of a CuArray object. and not all array abstractions have type signatures that cover SubArray

we could extend GPUArrays’ mean implementation to use AnyGPUArray (which includes SubArray) instead of AbstractGPUArray (only CuArray), but I’m hesitant to do that, because the horrible Union that is AnyGPUArray is bad for load time and creates lots of ambiguities. This needs a fix in Base, really

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants