From 3e1847dff6f7c765968f3631e98439db7fe9cde2 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Sun, 14 May 2023 17:37:57 -0700 Subject: [PATCH] Excise getindex adjoint We have a better rule in Chainrules now --- src/lib/array.jl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/lib/array.jl b/src/lib/array.jl index d65fea2c1..a3172bffb 100644 --- a/src/lib/array.jl +++ b/src/lib/array.jl @@ -41,24 +41,6 @@ end @adjoint (::Type{T})(sz) where {T<:Zeros} = T(sz), Δ->(nothing,) @adjoint (::Type{T})(sz) where {T<:Ones} = T(sz), Δ->(nothing,) -@adjoint getindex(x::AbstractArray, inds...) = x[inds...], ∇getindex(x, inds) - -@adjoint view(x::AbstractArray, inds...) = view(x, inds...), ∇getindex(x, inds) - -∇getindex(x::AbstractArray{T,N}, inds) where {T,N} = dy -> begin - if inds isa NTuple{N,Int} && T <: Number - dx = OneElement(dy, inds, axes(x)) - elseif inds isa NTuple{<:Any, Integer} - dx = _zero(x, typeof(dy)) - dx[inds...] = dy - else - dx = _zero(x, eltype(dy)) - dxv = view(dx, inds...) - dxv .= accum.(dxv, _droplike(dy, dxv)) - end - return (_project(x, dx), map(_->nothing, inds)...) -end - """ OneElement(val, ind, axes) <: AbstractArray