Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ext/RecursiveArrayToolsReverseDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ end
end
return Array(VA), Array_adjoint
end

@adjoint function Base.view(A::AbstractVectorOfArray{<:ReverseDiff.TrackedReal, N}, I::Colon...) where {N}
view_adjoint = let A = A, I = I
function (y)
A = recursivecopy(A)
trackedarraycopyto!(A, y)
(A, map(_ -> nothing, I)...)
end
end
return view(A, I...), view_adjoint
end

end # module
8 changes: 4 additions & 4 deletions ext/RecursiveArrayToolsZygoteExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ end
adj = let VA = VA
function Array_adjoint(y)
VA = recursivecopy(VA)
VA .= y
copyto!(VA, y)
return (VA,)
end
end
Expand All @@ -126,8 +126,8 @@ end
view_adjoint = let A = A, I = I
function (y)
A = recursivecopy(A)
A .= y
(A, map(_ -> nothing, I)...)
copyto!(A, y)
return (A, map(_ -> nothing, I)...)
end
end
return view(A, I...), view_adjoint
Expand All @@ -139,7 +139,7 @@ end
A = recursivecopy(A)
recursivefill!(A, zero(eltype(A)))
v = view(A, I...)
v .= y
copyto!(v, y)
return (A, map(_ -> nothing, I)...)
end
end
Expand Down