-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ReverseSequence #698
Add ReverseSequence #698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's redesign the interface a bit. I would default the dims
to nothing
. The behavior for that would be:
- If the input is
AbstractVector{T}
and!isbitstype(T)
then we simply callIterators.reverse
(note this is lazy) - For bitstype AbstractVector, call
reverse(x)
. - For other arrays, it calls
reverse(x; dims=ndims(x) - 1)
.
This essentially prevents unnecessary copies. For eg, for Bidirectional RNN we can simply construct an iterator once and make a lazy reverse iterator using this API without copying the entire array.
If dims
is specified,
AbstractVector{T}
and!isbitstype(T)
throws an error- All other array inputs call
reverse(x; dims=r.dims)
Hi, I'm curious why |
I have updated the implementation according to your guidance, except for the doubtful points above. |
test failed on gpu, I can't reproduce on local since I don't have AMDGPU or CUDA devices... |
I think it fails because g = CUDA.zeros(1)
gr = Iterators.reverse(g)
g .* gr |
Using |
I got a PC with GPU and test locally. I found |
Add this layer to the docs, also rebase with main. That will fix the doc build |
25325ea
to
e931a5e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #698 +/- ##
==========================================
- Coverage 87.34% 81.13% -6.21%
==========================================
Files 50 50
Lines 2505 2513 +8
==========================================
- Hits 2188 2039 -149
- Misses 317 474 +157 ☔ View full report in Codecov by Sentry. |
I noticed some test failures, should I follow up on this PR? Or leave all the rest to you? |
Github won't let me edit files directly. So if you add the docs to https://github.com/LuxDL/Lux.jl/blob/main/docs/src/api/Lux/layers.md#misc-helper-layers the build will pass |
I don't know if this is the correct implementation