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
12 changes: 7 additions & 5 deletions src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,13 @@ function __generic_matvecmul!(::typeof(identity), C::AbstractVector, A::Abstract
C[i] = zero(A[i]*B[1] + A[i]*B[1])
end
end
for k = eachindex(B)
aoffs = (k-1)*Astride
b = @stable_muladdmul MulAddMul(alpha,false)(B[k])
for i = eachindex(C)
C[i] += A[aoffs + i] * b
if !iszero(alpha)
for k = eachindex(B)
aoffs = (k-1)*Astride
b = @stable_muladdmul MulAddMul(alpha,false)(B[k])
for i = eachindex(C)
C[i] += A[aoffs + i] * b
end
end
end
end
Expand Down
20 changes: 16 additions & 4 deletions test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -980,11 +980,23 @@ Base.:*(x::Float64, a::A32092) = x * a.x
end

@testset "strong zero" begin
@testset for α in Any[false, 0.0, 0], n in 1:4
C = ones(n, n)
A = fill!(zeros(n, n), NaN)
B = ones(n, n)
@testset for α in Any[false, 0.0, 0], n in 1:4, T in (Float16, Float64)
C = ones(T, n)
A = fill(T(NaN), n, n)
B = ones(T, n)
@test mul!(copy(C), A, B, α, 1.0) == C
C = ones(T, n, n)
B = ones(T, n, n)
@test mul!(copy(C), A, B, α, 1.0) == C
end
@testset for α in Any[false, 0.0, 0], β in Any[false, 0.0, 0], n in 1:4, T in (Float16, Float64)
C = fill(T(NaN), n)
A = fill(T(NaN), n, n)
B = fill(T(NaN), n)
@test iszero(mul!(copy(C), A, B, α, β))
C = fill(T(NaN), n, n)
B = fill(T(NaN), n, n)
@test iszero(mul!(copy(C), A, B, α, β))
end
end

Expand Down