Skip to content

Commit b0c95b5

Browse files
Don't transpose empty MtlArrays (#658)
* Don't transpose empty MtlArrays * Add test
1 parent e0a86e2 commit b0c95b5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/linalg.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ end
245245
A::MtlMatrix{T}) where {T}
246246
axes(B, 2) == axes(A, 1) && axes(B, 1) == axes(A, 2) || throw(DimensionMismatch("transpose"))
247247

248+
isempty(B) && return B
249+
248250
M, N = size(A)
249251
dev = device()
250252
queue = global_queue(dev)

test/linalg.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,12 @@ using Metal: storagemode
108108
@test storagemode(lua.factors) == storagemode(lua.ipiv) == storagemode(A)
109109
end
110110

111+
@testset "transpose" begin
112+
A = MtlMatrix(rand(Float32, 0, 1024))
113+
B = Metal.zeros(Float32, 1024, 0)
114+
115+
# Issue #656
116+
@test isempty(transpose!(B, A))
117+
end
118+
111119
end

0 commit comments

Comments
 (0)