Skip to content
Draft
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: 1 addition & 1 deletion src/host/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function generic_matmatmul!(C::AbstractArray{R}, A::AbstractArray{T}, B::Abstrac
throw(DimensionMismatch("result C has dimensions $(size(C)), needs $((size(A,1),size(B,2)))"))
end
if isempty(A) || isempty(B)
return fill!(C, zero(R))
return rmul!(C, add.beta)
end

@kernel function matmatmul_kernel!(C, A, B)
Expand Down
20 changes: 20 additions & 0 deletions test/testsuite/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,16 @@ end
@test compare(mul!, AT, rand(T, 2,2), rand(T, 2,1), f(rand(T, 2)))
end
end

@testset "$T gemv zero-dim" for T in eltypes
y, A, x = rand(T, 4), rand(T, 4, 0), rand(T, 0)

@test compare(*, AT, A, x)
@test compare(mul!, AT, y, A, x)

y = rand(T, 4)
@test compare(mul!, AT, y, A, x, Ref(T(4)), Ref(T(5)))
end
end

@testsuite "linalg/mul!/matrix-matrix" (AT, eltypes)->begin
Expand All @@ -434,6 +444,16 @@ end
@test compare(mul!, AT, C, f(A), g(B), Ref(T(4)), Ref(T(5)))
@test typeof(AT(rand(T, 3, 3)) * AT(rand(T, 3, 3))) <: AbstractMatrix
end

@testset "$T gemm zero-dim" for T in eltypes
A, B, C = rand(T, 4, 0), rand(T, 0, 4), rand(T, 4, 4)

@test compare(*, AT, A, B)
@test compare(mul!, AT, C, A, B)

C = rand(T, 4, 4)
@test compare(mul!, AT, C, A, B, Ref(T(4)), Ref(T(5)))
end
end

@testsuite "linalg/norm" (AT, eltypes)->begin
Expand Down
Loading