Skip to content

Commit b761bd5

Browse files
authored
Restrict dest in 5-arg mul! (JuliaArrays#825)
1 parent 301e082 commit b761bd5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/matrix_multiply_add.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,18 @@ Base.transpose(::TSize{S,:any}) where {S,T} = TSize{reverse(S),:transpose}()
204204
@inline mul_parent(A::StaticMatrix) = A
205205
@inline mul_parent(A::StaticVector) = A
206206

207+
# Using the full StaticVecOrMatLike in dest of that one method of mul! takes a lot of load time
208+
const StaticVecOrMatLikeForFiveArgMulDest{T} = Union{
209+
StaticVector{<:Any, T},
210+
StaticMatrix{<:Any, <:Any, T},
211+
Transpose{T, <:StaticVecOrMat{T}},
212+
Adjoint{T, <:StaticVecOrMat{T}}
213+
}
214+
207215
# 5-argument matrix multiplication
208216
# To avoid allocations, strip away Transpose type and store tranpose info in Size
209-
@inline LinearAlgebra.mul!(dest::StaticVecOrMatLike, A::StaticVecOrMatLike, B::StaticVecOrMatLike,
210-
α::Real, β::Real) = _mul!(TSize(dest), mul_parent(dest), Size(A), Size(B), A, B,
217+
@inline LinearAlgebra.mul!(dest::StaticVecOrMatLikeForFiveArgMulDest, A::StaticVecOrMatLike, B::StaticVecOrMatLike,
218+
α::Number, β::Number) = _mul!(TSize(dest), mul_parent(dest), Size(A), Size(B), A, B,
211219
AlphaBeta(α,β))
212220

213221
@inline function LinearAlgebra.mul!(dest::StaticVecOrMatLike{TDest}, A::StaticVecOrMatLike{TA},
@@ -601,3 +609,4 @@ end
601609
@inline mul_blas!(Sc::TSize{<:Any,:transpose}, c::StaticMatrix, Sa::TSize, Sb::TSize,
602610
a::StaticMatrix, b::StaticMatrix, _add::MulAddMul) =
603611
mul_blas!(transpose(Sc), c, transpose(Sb), transpose(Sa), b, a, _add)
612+

0 commit comments

Comments
 (0)