From 8c61928e8d004fa352cda035cb87e48bdd7fe42c Mon Sep 17 00:00:00 2001 From: Lorenzo Van Munoz <66997677+lxvm@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:20:11 -0500 Subject: [PATCH] Apply suggestions from code review Remove `Val` from `ntuple`s where constant propagation occurs Co-authored-by: Brian Chen --- src/lib/array.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/array.jl b/src/lib/array.jl index b152d06d6..fe0438b5a 100644 --- a/src/lib/array.jl +++ b/src/lib/array.jl @@ -138,7 +138,7 @@ struct StaticGetter{i} end (::StaticGetter{i})(v) where {i} = v[i] (::StaticGetter{i})(::Nothing) where {i} = nothing function _unzip(tuples, ::Val{N}) where {N} - getters = ntuple(n -> StaticGetter{n}(), Val(N)) + getters = ntuple(n -> StaticGetter{n}(), N) map(g -> map(g, tuples), getters) end function unzip(tuples) @@ -276,7 +276,7 @@ function productfunc(xs, dy) @assert length(first(dy)) == length(xs) ndim = map(Zygote._ndims, xs) cdim = cumsum((1, ndim[begin:end-1]...)) - getters = ntuple(n -> StaticGetter{n}(), Val(length(xs))) + getters = ntuple(n -> StaticGetter{n}(), length(xs)) map(first(dy), xs, cdim, getters) do dyn, x, cd, getter dyn === nothing && return nothing nd = _ndims(x) @@ -300,7 +300,7 @@ end end function zipfunc(xs, dy) - getters = ntuple(n -> StaticGetter{n}(), Val(length(xs))) + getters = ntuple(n -> StaticGetter{n}(), length(xs)) map(xs, getters) do x, getter dx = map(getter, dy) _project(x, _restore(dx, _tryaxes(x)))