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
8 changes: 8 additions & 0 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -946,3 +946,11 @@ function Base.resize!(A::CuVector{T}, n::Integer) where T
A.dims = (n,)
return A
end


# CUBLAS.geam! is much faster than the generic implementation of transpose! in GPUArrays:
function LinearAlgebra.transpose!(dest::CuMatrix{T}, src::CuMatrix{T}) where {T <: Union{Float32, Float64, ComplexF32, ComplexF64}}
axes(dest) == reverse(axes(src)) || throw(DimensionMismatch("axes of the destination are incompatible with that of the source"))
CUDA.CUBLAS.geam!('T', 'T', one(T), src, zero(T), src, dest)
return dest
end
10 changes: 10 additions & 0 deletions test/base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,16 @@ end
@test c === a
end

@testset "transpose!" begin
for T in [Float32, Float64, ComplexF32, ComplexF64]
a = CUDA.rand(T, 10, 20)
b = similar(a, reverse(size(a)))
c = similar(a)
@test Array(transpose!(b, a)) == transpose(Array(a))
@test_throws DimensionMismatch transpose!(c, a)
end
end

@testset "issue 2595" begin
# mixed-type reductions resulted in a deadlock because of union splitting over shfl
a = CUDA.zeros(Float32, 1)
Expand Down