@@ -30,11 +30,11 @@ function DI.value_and_pullback(
3030) where {F,Y,C}
3131 DI. check_prep (f, prep, backend, x, ty, contexts... )
3232 dy = only (ty)
33- dy_righttype = dy isa tangent_type (Y) ? dy : copyto! ! (prep. dy_righttype, dy)
33+ dy_righttype = dy isa tangent_type (Y) ? dy : _copy_to_output ! (prep. dy_righttype, dy)
3434 new_y, (_, new_dx) = value_and_pullback!! (
3535 prep. cache, dy_righttype, f, x, map (DI. unwrap, contexts)...
3636 )
37- return new_y, (mycopy (new_dx),)
37+ return new_y, (_copy_output (new_dx),)
3838end
3939
4040function DI. value_and_pullback (
@@ -47,11 +47,11 @@ function DI.value_and_pullback(
4747) where {F,Y,C}
4848 DI. check_prep (f, prep, backend, x, ty, contexts... )
4949 ys_and_tx = map (ty) do dy
50- dy_righttype = dy isa tangent_type (Y) ? dy : copyto! ! (prep. dy_righttype, dy)
50+ dy_righttype = dy isa tangent_type (Y) ? dy : _copy_to_output ! (prep. dy_righttype, dy)
5151 y, (_, new_dx) = value_and_pullback!! (
5252 prep. cache, dy_righttype, f, x, map (DI. unwrap, contexts)...
5353 )
54- y, mycopy (new_dx)
54+ y, _copy_output (new_dx)
5555 end
5656 y = first (ys_and_tx[1 ])
5757 tx = last .(ys_and_tx)
@@ -126,7 +126,7 @@ function DI.value_and_gradient(
126126) where {F,C}
127127 DI. check_prep (f, prep, backend, x, contexts... )
128128 y, (_, new_grad) = value_and_gradient!! (prep. cache, f, x, map (DI. unwrap, contexts)... )
129- return y, mycopy (new_grad)
129+ return y, _copy_output (new_grad)
130130end
131131
132132function DI. value_and_gradient! (
0 commit comments