-
Notifications
You must be signed in to change notification settings - Fork 233
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
view() returns CuArray instead of view for 1-D CuArrays #2566
Comments
|
Thanks for looking into this, @maleadt . For multi-dimensional arrays, it creates a julia> using CUDA
julia> nx = ny = nz = 3;
julia> B = CUDA.zeros(nx);
julia> C = CUDA.zeros(nx,ny);
julia> D = CUDA.zeros(nx,ny,nz);
julia> E = zeros(nx);
julia> F = zeros(nx,ny);
julia> G = zeros(nx,ny,nz);
julia> typeof(view(B, 1:nx))
CuArray{Float32, 1, CUDA.DeviceMemory}
julia> typeof(view(C, 1:nx, 1:ny))
SubArray{Float32, 2, CuArray{Float32, 2, CUDA.DeviceMemory}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}
julia> typeof(view(D, 1:nx, 1:ny, 1:nz))
SubArray{Float32, 3, CuArray{Float32, 3, CUDA.DeviceMemory}, Tuple{UnitRange{Int64}, UnitRange{Int64}, UnitRange{Int64}}, false}
julia> typeof(view(E, 1:nx))
SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}
julia> typeof(view(F, 1:nx, 1:ny))
SubArray{Float64, 2, Matrix{Float64}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}
julia> typeof(view(G, 1:nx, 1:ny, 1:nz))
SubArray{Float64, 3, Array{Float64, 3}, Tuple{UnitRange{Int64}, UnitRange{Int64}, UnitRange{Int64}}, false} |
That's correct. It tries to figure out if the view is contiguous. If it may be, a CuArray is returned. Why is this a problem? |
Wouldn't it be more helpful for the programmer if it returns always a SubArray for views on CuArrays? Also, that's the behavior for |
I get what you're asking and why, but this won't change. There is no contract for these calls to return a |
@maleadt Okay, I understand. Thanks for clarifying the situation! |
MWE:
The text was updated successfully, but these errors were encountered: