Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal authored Jun 15, 2024
1 parent 497fcb3 commit 42ec87a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/layers/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Reverse the specified dimension `dims` of the passed array
## Inputs
- `x`: AbstractArray of any shape.
- `x`: AbstractArray.
## Returns
- AbstractArray with the same dimensions as the input
- Empty `NamedTuple()`
"""
@kwdef @concrete struct ReverseSequence <: AbstractExplicitLayer
dim = nothing
@kwdef struct ReverseSequence{D <: Union{Int, Nothing}} <: AbstractExplicitLayer
dim::D = nothing
end

@inline function (r::ReverseSequence{Nothing})(
Expand All @@ -64,11 +64,8 @@ end
end

@inline function (r::ReverseSequence)(x::AbstractVector{T}, ps, st::NamedTuple) where {T}
if r.dim == 1
return reverse(x), st
else
throw(DimensionMismatch(lazy"Cannot specify a dimension other than 1 for AbstractVector{T}"))
end
r.dim == 1 && return reverse(x), st
throw(DimensionMismatch(lazy"Cannot specify a dimension other than 1 for AbstractVector{T}"))
end

@inline function (r::ReverseSequence)(
Expand Down

0 comments on commit 42ec87a

Please sign in to comment.