Skip to content

Commit

Permalink
Fix 5-arg mul! for tiled generic case (#33218)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf authored and KristofferC committed Sep 11, 2019
1 parent 2d4f4d2 commit 09ff912
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat
if isone(_add.alpha) && iszero(_add.beta)
copyto!(C, ib:ilim, jb:jlim, Ctile, 1:ilen, 1:jlen)
else
C[ib:ilim, jb:jlim] .= @views _add.(C[ib:ilim, jb:jlim], Ctile[1:ilen, 1:jlen])
C[ib:ilim, jb:jlim] .= @views _add.(Ctile[1:ilen, 1:jlen], C[ib:ilim, jb:jlim])
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions stdlib/LinearAlgebra/test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,20 @@ end
@test mul!(view(C, 1:10, 1:10), A, 0.5) == A * 0.5
end

@testset "Issue #33214: tiled generic mul!" begin
n = 100
A = rand(n, n)
B = rand(n, n)
C = zeros(n, n)
mul!(C, A, B, -1, 0)
D = -A * B
@test D C

# Just in case dispatching on the surface API `mul!` is changed in the future,
# let's test the function where the tiled multiplication is defined.
fill!(C, 0)
LinearAlgebra._generic_matmatmul!(C, 'N', 'N', A, B, LinearAlgebra.MulAddMul(-1, 0))
@test D C
end

end # module TestMatmul

0 comments on commit 09ff912

Please sign in to comment.