Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/StridedViewsAMDGPUExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ using AMDGPU: Adapt

const ROCStridedView{T, N, A <: ROCArray{T}} = StridedView{T, N, A}

StridedViews._normalizeparent(A::ROCArray, offset::Int) = reshape(A, length(A)), offset

function Base.pointer(x::ROCStridedView{T}) where {T}
return Base.unsafe_convert(Ptr{T}, pointer(x.parent, x.offset + 1))
end
Expand Down
2 changes: 2 additions & 0 deletions ext/StridedViewsCUDACoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ using CUDACore: Adapt, CuPtr

const CuStridedView{T, N, A <: CuArray{T}} = StridedView{T, N, A}

StridedViews._normalizeparent(A::CuArray, offset::Int) = reshape(A, length(A)), offset

function Base.pointer(x::CuStridedView{T}) where {T}
return Base.unsafe_convert(CuPtr{T}, pointer(x.parent, x.offset + 1))
end
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,14 @@ end
if CUDACore.functional()
@testset "CuArrays with StridedView" begin
@testset for T in (Float64, ComplexF64)
A = CUDACore.randn(T, 10, 10, 10, 10)
A = CuArray(randn(T, 10, 10, 10, 10))
@test isstrided(A)
B = StridedView(A)
@test B isa StridedView
@test parent(B) isa CuArray{T, 1}
CUDACore.@allowscalar begin
@test B == A
@test parent(B) == reshape(A, :)
end
end
end
Expand All @@ -368,8 +370,10 @@ if AMDGPU.functional()
@test isstrided(A)
B = StridedView(A)
@test B isa StridedView
@test parent(B) isa ROCArray{T, 1}
AMDGPU.@allowscalar begin
@test B == A
@test parent(B) == reshape(A, :)
end
end
end
Expand Down
Loading