Skip to content

Commit 6edfce9

Browse files
committed
Excise getindex adjoint
We have a better rule in Chainrules now
1 parent 415ec0a commit 6edfce9

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

src/lib/array.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,6 @@ end
4141
@adjoint (::Type{T})(sz) where {T<:Zeros} = T(sz), Δ->(nothing,)
4242
@adjoint (::Type{T})(sz) where {T<:Ones} = T(sz), Δ->(nothing,)
4343

44-
@adjoint getindex(x::AbstractArray, inds...) = x[inds...], ∇getindex(x, inds)
45-
46-
@adjoint view(x::AbstractArray, inds...) = view(x, inds...), ∇getindex(x, inds)
47-
48-
∇getindex(x::AbstractArray{T,N}, inds) where {T,N} = dy -> begin
49-
if inds isa NTuple{N,Int} && T <: Number
50-
dx = OneElement(dy, inds, axes(x))
51-
elseif inds isa NTuple{<:Any, Integer}
52-
dx = _zero(x, typeof(dy))
53-
dx[inds...] = dy
54-
else
55-
dx = _zero(x, eltype(dy))
56-
dxv = view(dx, inds...)
57-
dxv .= accum.(dxv, _droplike(dy, dxv))
58-
end
59-
return (_project(x, dx), map(_->nothing, inds)...)
60-
end
61-
6244
"""
6345
OneElement(val, ind, axes) <: AbstractArray
6446

0 commit comments

Comments
 (0)