Skip to content

Commit

Permalink
fixup! fix: fix view adjoints
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed May 30, 2024
1 parent 97edb58 commit 5770229
Showing 1 changed file with 12 additions and 0 deletions.
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)...)

Check warning on line 32 in ext/RecursiveArrayToolsReverseDiffExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/RecursiveArrayToolsReverseDiffExt.jl#L27-L32

Added lines #L27 - L32 were not covered by tests
end
end
return view(A, I...), view_adjoint

Check warning on line 35 in ext/RecursiveArrayToolsReverseDiffExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/RecursiveArrayToolsReverseDiffExt.jl#L35

Added line #L35 was not covered by tests
end

end # module

0 comments on commit 5770229

Please sign in to comment.