Skip to content

Commit 6c9048c

Browse files
committed
include comment to explain view
1 parent de07109 commit 6c9048c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/stage1/generated.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,12 @@ function (::∂⃖{N})(::typeof(Base.getindex), a::Array{<:Number}, inds...) whe
320320
(@Base.constprop :aggressive Δ->begin
321321
Δ isa AbstractZero && return (NoTangent(), Δ, map(Returns(Δ), inds)...)
322322
BB = zero(a)
323+
324+
# view is needed to cover cases with duplicated indices like
325+
# gradient(sum ∘ x -> x[:,[1,1,2]], rand(3,4))
326+
# https://github.com/JuliaDiff/Diffractor.jl/pull/254#discussion_r1480791644
323327
view(BB, inds...) .+= unthunk(Δ)
328+
324329
(NoTangent(), BB, map(x->NoTangent(), inds)...)
325330
end),
326331
(@Base.constprop :aggressive (_, Δ, _)->begin

0 commit comments

Comments
 (0)