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

Improve transpose, adjoint of vector StridedView #5

Merged
merged 5 commits into from
Dec 15, 2023
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
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StridedViews"
uuid = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143"
authors = ["Lukas Devos <lukas.devos@ugent.be>", "Jutho Haegeman <jutho.haegeman@ugent.be>"]
version = "0.2.1"
version = "0.2.2"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand All @@ -15,8 +15,12 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
StridedViewsCUDAExt = "CUDA"

[compat]
Aqua = "0.8"
CUDA = "4,5"
LinearAlgebra = "1.6"
PackageExtensionCompat = "1"
Random = "1.6"
Test = "1.6"
julia = "1.6"

[extras]
Expand Down
7 changes: 7 additions & 0 deletions src/stridedview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ end

sreshape(a::AbstractArray, newsize::Dims) = sreshape(StridedView(a), newsize)

function sreshape(a::LinearAlgebra.AdjointAbsVec, newsize::Dims)
return sreshape(conj(StridedView(adjoint(a))), newsize)
end
function sreshape(a::LinearAlgebra.TransposeAbsVec, newsize::Dims)
return sreshape(StridedView(transpose(a)), newsize)
end

# Other methods: `similar`, `copy`
#----------------------------------
function Base.similar(a::StridedView, ::Type{T}, dims::NTuple{N,Int}) where {N,T}
Expand Down
12 changes: 10 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ Random.seed!(1234)
end
end

@testset "transpose and adjoint with vector StridedView" begin
@testset for T in (Float32, Float64, Complex{Float32}, Complex{Float64})
A = randn(T, (60,))

@test sreshape(transpose(A), (1, length(A))) == transpose(A)
@test sreshape(adjoint(A), (1, length(A))) == adjoint(A)
end
end

@testset "elementwise conj, transpose and adjoint" begin
@testset for T in (Float32, Float64, Complex{Float32}, Complex{Float64})
A = [rand(T) for i in 1:5, b in 1:4, c in 1:3, d in 1:2]
Expand Down Expand Up @@ -206,5 +215,4 @@ end
end

using Aqua
Aqua.test_all(StridedViews;
project_toml_formatting=(VERSION >= v"1.9"))
Aqua.test_all(StridedViews)