Skip to content

Commit e8073ba

Browse files
Add a missing dispatch
@avik-pal this needs `fmap` and thus a Functors.jl dependency. Could that be avoided somehow or is it necessary? I would guess you could turn it into a componentarray and then apply `backing`?
1 parent 02c95fe commit e8073ba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/compat/chainrulescore.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ function ChainRulesCore.ProjectTo(ca::ComponentArray)
1717
end
1818

1919
(p::ChainRulesCore.ProjectTo{ComponentArray})(dx::AbstractArray) = ComponentArray(p.project(dx), p.axes)
20+
21+
function (p::ChainRulesCore.ProjectTo{ComponentArray})(t::ChainRulesCore.Tangent{A, <:NamedTuple}) where {A}
22+
nt = fmap(ChainRulesCore.backing, ChainRulesCore.backing(t))
23+
return ComponentArray(nt)
24+
end

0 commit comments

Comments
 (0)