Skip to content

Commit

Permalink
Update utils.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott authored Jan 3, 2025
1 parent 204b958 commit e3971bd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ end
@non_differentiable _partition_idxs(::Any...)

# Similar to ∇eachslice https://github.com/JuliaDiff/ChainRules.jl/blob/8108a77a96af5d4b0c460aac393e44f8943f3c5e/src/rulesets/Base/indexing.jl#L77
function ∇chunk(dys, x, idxs, vd::Val{dim}) where {dim}
function ∇chunk(dys_raw, x, idxs, vd::Val{dim}) where {dim}
dys = unthunk.(unthunk(dys_raw)) # https://github.com/FluxML/Zygote.jl/pull/966#issuecomment-2569227272
i1 = findfirst(dy -> !(dy isa AbstractZero), dys)
if i1 === nothing # all slices are Zero!
return _zero_fill!(similar(x, float(eltype(x))))
Expand Down

0 comments on commit e3971bd

Please sign in to comment.