Skip to content

Commit dedc7ce

Browse files
authored
Merge pull request #2023 from FluxML/bc/lstm-muladd
Use muladd for LSTM cell matmuls
2 parents d214600 + f1961d6 commit dedc7ce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/layers/recurrent.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ end
295295

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

0 commit comments

Comments
 (0)