Skip to content

1-element view not recognized as contiguous #2653

Open
@maleadt

Description

@maleadt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions