From abde997074c24580a92e531d7b38993f019520d3 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Wed, 18 Aug 2021 23:09:10 -0400 Subject: [PATCH] accept Tuple Tangent for arrays --- src/projection.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/projection.jl b/src/projection.jl index 7be03e60c..a01774522 100644 --- a/src/projection.jl +++ b/src/projection.jl @@ -241,6 +241,12 @@ function (project::ProjectTo{AbstractArray})(dx::Number) # ... so we restore fro return fill(project.element(dx)) end +# Accept the Tangent corresponding to a Tuple -- Zygote's splats produce these +function (project::ProjectTo{AbstractArray})(dx::Tangent{<:Any, <:Tuple}) + dy = reshape(collect(backing(dx)), project.axes) + return project(dy) +end + # Ref -- works like a zero-array, also allows restoration from a number: ProjectTo(x::Ref) = ProjectTo{Ref}(; x=ProjectTo(x[])) (project::ProjectTo{Ref})(dx::Ref) = Ref(project.x(dx[]))