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

1-element view not recognized as contiguous #2653

Open
maleadt opened this issue Feb 13, 2025 · 0 comments
Open

1-element view not recognized as contiguous #2653

maleadt opened this issue Feb 13, 2025 · 0 comments
Labels
cuda array Stuff about CuArray. good first issue Good for newcomers

Comments

@maleadt
Copy link
Member

maleadt commented Feb 13, 2025

Something funny I discovered while trying to write tests for this:

julia> A = CuArray(randn(ComplexF32, 5));

julia> vA = @view A[2:5];

julia> rvA = reshape(vA, (4,1));

julia> typeof(rvA)
CuArray{ComplexF32, 2, CUDA.DeviceMemory}

julia> B = CuArray(randn(ComplexF32, 4, 5));

julia> vB = @view B[1:1, 1:1];

julia> rvB = reshape(vB, (1,1));

julia> typeof(rvB)
Base.ReshapedArray{ComplexF32, 2, SubArray{ComplexF32, 2, CuArray{ComplexF32, 2, CUDA.DeviceMemory}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}

@maleadt this seems a bit sus to me although I suspect there's a good reason for it!

Originally posted by @kshyatt in #2407

Looks like a bug; the @view B[1:1, 1:1] isn't deemed contiguous, so we hit the generic fallback. The logic for that is here, in case anybody wants to take a look https://github.com/JuliaGPU/GPUArrays.jl/blob/174bba1303a098029d2964fa16db775adddcc22a/src/host/base.jl#L302-L320

@maleadt maleadt added good first issue Good for newcomers cuda array Stuff about CuArray. labels Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda array Stuff about CuArray. good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant