Skip to content

Commit

Permalink
Unthunk each element in ∇eachslice
Browse files Browse the repository at this point in the history
  • Loading branch information
pxl-th committed Dec 25, 2024
1 parent e055009 commit 51c745f
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/rulesets/Base/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,7 @@ end
# Using Val(dim) here is worth a factor of 2 in this, on Julia 1.8-
# @btime rrule(eachcol, $([1 2; 3 4]))[2]($([[10, 20], [30, 40]]))
function ∇eachslice(dys_raw, x::AbstractArray, vd::Val{dim}) where {dim}
dys = unthunk(dys_raw)
i1 = findfirst(dy -> dy isa AbstractArray, dys)
if i1 === nothing # all slices are Zero!
return _zero_fill!(similar(x, float(eltype(x)), axes(x)))
end
dys = unthunk.(unthunk(dys_raw))
T = Base.promote_eltype(dys...)
# The whole point of this gradient is that we can allocate one `dx` array:
dx = similar(x, T, axes(x))
Expand Down

0 comments on commit 51c745f

Please sign in to comment.