@@ -452,7 +452,7 @@ function _value_and_pullback_via_pushforward(
452452 dy,
453453 contexts:: Vararg{Context, C} ,
454454 ) where {F, C}
455- a = last (value_and_pushforward (f!, y, pushforward_prep, backend, x, (oneunit (x),), contexts... ))
455+ _, a = onlysecond (value_and_pushforward (f!, y, pushforward_prep, backend, x, (oneunit (x),), contexts... ))
456456 dx = dot (a, dy)
457457 return dx
458458end
@@ -467,7 +467,7 @@ function _value_and_pullback_via_pushforward(
467467 contexts:: Vararg{Context, C} ,
468468 ) where {F, C}
469469 a = only (pushforward (f!, y, pushforward_prep, backend, x, (oneunit (x),), contexts... ))
470- b = last (
470+ _, b = onlysecond (
471471 value_and_pushforward (f!, y, pushforward_prep, backend, x, (im * oneunit (x),), contexts... )
472472 )
473473 dx = real (dot (a, dy)) + im * real (dot (b, dy))
@@ -484,7 +484,7 @@ function _value_and_pullback_via_pushforward(
484484 contexts:: Vararg{Context, C} ,
485485 ) where {F, C}
486486 dx = map (CartesianIndices (x)) do j # preserve shape
487- a = last (value_and_pushforward (f!, y, pushforward_prep, backend, x, (basis (x, j),), contexts... ))
487+ _, a = onlysecond (value_and_pushforward (f!, y, pushforward_prep, backend, x, (basis (x, j),), contexts... ))
488488 dot (a, dy)
489489 end
490490 return dx
@@ -501,7 +501,7 @@ function _value_and_pullback_via_pushforward(
501501 ) where {F, C}
502502 dx = map (CartesianIndices (x)) do j # preserve shape
503503 a = only (pushforward (f!, y, pushforward_prep, backend, x, (basis (x, j),), contexts... ))
504- b = last (
504+ _, b = onlysecond (
505505 value_and_pushforward (
506506 f!, y, pushforward_prep, backend, x, (im * basis (x, j),), contexts...
507507 ),
0 commit comments