File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -118,15 +118,21 @@ end
118
118
Array (VA), adj
119
119
end
120
120
121
+ @adjoint function Base. view (A:: AbstractVectorOfArray , I:: Colon... )
122
+ function adjoint (y)
123
+ (recursivecopy (parent (y)), map (_ -> nothing , I)... )
124
+ end
125
+ return view (A, I... ), adjoint
126
+ end
127
+
121
128
@adjoint function Base. view (A:: AbstractVectorOfArray , I... )
122
- adj = let A = A, I = I
123
- function view_adjoint (y)
124
- A = zero (A)
125
- view (A, I... ) .= y
126
- return (A, map (_ -> nothing , I)... )
127
- end
129
+ function view_adjoint (y)
130
+ A = recursivecopy (parent (y))
131
+ recursivefill! (A, zero (eltype (A)))
132
+ A[I... ] .= y
133
+ return (A, map (_ -> nothing , I)... )
128
134
end
129
- view (A, I... ), adj
135
+ view (A, I... ), view_adjoint
130
136
end
131
137
132
138
ChainRulesCore. ProjectTo (a:: AbstractVectorOfArray ) = ChainRulesCore. ProjectTo {VectorOfArray} ((sz = size (a)))
You can’t perform that action at this time.
0 commit comments