Skip to content

Commit

Permalink
More efficient ntuple generation in unsqueeze w/ Val
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick authored Oct 9, 2024
1 parent 204b958 commit 72c8d0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ julia> unsqueeze(xs, dims=1)
"""
function unsqueeze(x::AbstractArray{T,N}; dims::Int) where {T, N}
@assert 1 <= dims <= N + 1
sz = ntuple(i -> i < dims ? size(x, i) : i == dims ? 1 : size(x, i - 1), N + 1)
sz = ntuple(i -> i < dims ? size(x, i) : i == dims ? 1 : size(x, i - 1), Val(N + 1))
return reshape(x, sz)
end

Expand Down

0 comments on commit 72c8d0f

Please sign in to comment.