Skip to content

Fix recursion performance #61

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

Merged
merged 4 commits into from
Jan 17, 2023
Merged

Conversation

gaurav-arya
Copy link
Contributor

@gaurav-arya gaurav-arya commented Jan 16, 2023

This PR simplifies the recursive structure of walking a functor. It uses a trick from JuliaLang/julia#47760 to resolve #59.

The functionality of fmap after this PR is identical to its previous one. Thus, this PR lays bare the fact that the argument f is ultimately useless for the version of fmap that takes a user-specified walk. Note that this was public API, however, so I kept it in the signature and added an explanatory note.

Obviously the fmap API is highly imperfect, but I think this PR is a strict improvement, that simply lays bare some of the issues. (Ultimately, I think that the use of fmap with a user-specified arbitrary walk should probably be deprecated: walks are just way too flexible to allow arbitrary walks to be paired with fmap. The semantics of fmap seem to match best with the specific use case of ExcludeWalk: ExcludeWalk is what actually uses f, after all. The general function allowing for arbitrary walks should probably be called recursivewalk or something. But that would be very breaking.)

Copy link
Member

@darsnack darsnack left a comment

Choose a reason for hiding this comment

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

Are there packages outside Flux using the walk-based API? Better to make a breaking change soon before more people adopt the new (bad) API.

Copy link
Member

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

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

Thanks! Just a couple of formatting nits from me.

Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>
@ToucheSir ToucheSir merged commit 0830691 into FluxML:master Jan 17, 2023
@gaurav-arya
Copy link
Contributor Author

I don't believe this has got a release?

@ToucheSir
Copy link
Member

I don't remember why. Might've held off because of the recent TagBot issues that prevented tags and release notes from being published. See JuliaRegistries/General#77862

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.

Recursive inference failure for multiple functors
3 participants