Merge #907
907: Change `gate` function to `view` instead of copy r=MikeInnes a=janEbert This speeds up code with large inputs by quite a lot. I only added it to the function accepting an `AbstractVector` as input as copying matrices may be faster than viewing them due to caching (they are sliced per row so will the data will not necessarily have a low stride). Co-authored-by: janEbert <janpublicebert@posteo.net>
This commit is contained in:
commit
7104fd9332
@ -1,5 +1,5 @@
|
||||
gate(h, n) = (1:h) .+ h*(n-1)
|
||||
gate(x::AbstractVector, h, n) = x[gate(h,n)]
|
||||
gate(x::AbstractVector, h, n) = @view x[gate(h,n)]
|
||||
gate(x::AbstractMatrix, h, n) = x[gate(h,n),:]
|
||||
|
||||
# Stateful recurrence
|
||||
|
Loading…
Reference in New Issue
Block a user