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

Test-suite improvements. #566

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Test-suite improvements. #566

merged 1 commit into from
Oct 22, 2024

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Oct 22, 2024

The most important change here is to rely on adapt(AT, x) instead of rolling our own adaptor that uses the array type constructor, since the former may have some more functionality registered with it. Specifically:

julia> x = view(rand(Float32, 100, 100), 2:99, 2:99);

julia> typeof(x)
SubArray{Float32, 2, Matrix{Float32}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}

julia> x isa StridedArray
true
julia> struct ArrayAdaptor{AT} end

julia> Adapt.adapt_storage(::ArrayAdaptor{AT}, xs::AbstractArray) where {AT} = AT(xs)

julia> y = adapt(ArrayAdaptor{CuArray}(), x);

julia> typeof(y)
SubArray{Float32, 2, CuArray{Float32, 2, CUDA.DeviceMemory}, Tuple{CuArray{Int64, 1, CUDA.DeviceMemory}, CuArray{Int64, 1, CUDA.DeviceMemory}}, false}

julia> y isa StridedCuArray
false
julia> z = adapt(CuArray, x);

julia> typeof(z)
SubArray{Float32, 2, CuArray{Float32, 2, CUDA.DeviceMemory}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}

julia> z isa StridedCuArray
true

This may also be a bug we need to fix in Adapt, but it seems fine to rely more on adapt(AT, x) anyway.

@maleadt maleadt merged commit 44043dd into master Oct 22, 2024
12 checks passed
@maleadt maleadt deleted the tb/testsuite branch October 22, 2024 12:42
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

Successfully merging this pull request may close these issues.

1 participant