Skip to content

Commit

Permalink
Merge pull request #2023 from FluxML/bc/lstm-muladd
Browse files Browse the repository at this point in the history
Use muladd for LSTM cell matmuls
  • Loading branch information
ToucheSir authored Sep 4, 2022
2 parents d214600 + f1961d6 commit dedc7ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/layers/recurrent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ end

function (m::LSTMCell{A,V,<:NTuple{2,AbstractMatrix{T}}})((h, c), x::Union{AbstractVecOrMat{T},OneHotArray}) where {A,V,T}
b, o = m.b, size(h, 1)
g = m.Wi*x .+ m.Wh*h .+ b
g = muladd(m.Wi, x, muladd(m.Wh, h, b))
input, forget, cell, output = multigate(g, o, Val(4))
c′ = @. sigmoid_fast(forget) * c + sigmoid_fast(input) * tanh_fast(cell)
h′ = @. sigmoid_fast(output) * tanh_fast(c′)
Expand Down

0 comments on commit dedc7ce

Please sign in to comment.