Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _pullback inside rules instead of pullback #1385

Merged
merged 2 commits into from
Mar 7, 2023
Merged

Conversation

ToucheSir
Copy link
Member

This will give us more flexibility to implement internal changes such as #603 without changing the user-facing API.

This will give us more flexibility to implement internal changes such as
#603 without changing the user-facing API.
@@ -279,7 +279,10 @@ end
enumerate(xs), back
end

@adjoint Iterators.Filter(f, x) = pullback(filter, f, collect(x))
function _pullback(cx::AContext, ::Type{<:Iterators.Filter}, f, x)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note on why these are _pullback instead of @adjoint: @adjoint tries to do some clever postprocessing of the pullback return which results in mismatched results (differential arg tuple off by one). Using _pullback is slightly more code and requires a bit more care, but it removes a few layers from the call stack and brings us closer to removing @adjoint completely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when Miha and I were trying to get rid of Zygote's own types we likewise removed some uses of @adjoint and wrote the _pullback overloads directly

Copy link
Member

@oxinabox oxinabox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tests pass them this LGTM

@ToucheSir ToucheSir merged commit 7cbd21f into master Mar 7, 2023
@ToucheSir ToucheSir deleted the bc/_pullback-inside branch March 7, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants