-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Allow shared parameters, take III #106
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9b28112
allow shared parameters, take III
mcabbott 64d5d9f
one more dict to allow artificial ties
mcabbott 670e49a
a tidier idea, just replace _default_walk
mcabbott 6db7a36
add a LeafCache type, to make fmap ignore () singleton
mcabbott 5e5d5db
remove leaf.frozen field
mcabbott 522f66a
eager accumulation
mcabbott 3172f13
give up on customising fmap & write the recursion, add evil tests
mcabbott 37521c8
add ismutable check
mcabbott 0d6619a
docs etc
mcabbott d13e52a
fix doctests
mcabbott 1577b88
group the tests
mcabbott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Optimisers" | ||
uuid = "3bd65402-5787-11e9-1adc-39752487f4e2" | ||
authors = ["Mike J Innes <[email protected]>"] | ||
version = "0.2.9" | ||
version = "0.2.10" | ||
|
||
[deps] | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
|
@@ -12,7 +12,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | |
|
||
[compat] | ||
ChainRulesCore = "1" | ||
Functors = "0.2.8, 0.3" | ||
Functors = "0.3" | ||
Zygote = "0.6.40" | ||
julia = "1.6" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does imply we will be caching almost every level of an average Flux model (since
BitsType{NotBits, BitsTypes...}
is not a bitstype).objectid
being not the fastest function in the world, perhaps both cache lookup and insertion should be additionally guarded byismutable(x)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered this too. For large ImmutableArrays this may eventually need something fancier. But for now I think every
fmap
walk does the same thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I wasn't even thinking about those, but cases like JuliaLang/julia#43542. We're unlikely to see any truly pathological behaviour, but I have to imagine the single comparison
ismutable
makes is more efficient than the recursive hash functionobjectid
uses.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I guess
ismutable
really is right here. For parameter arrays IIRC there was a concern that it tells you e.g. that PermutedDimsArray is immutable. But for known non-leaf types, maybe it's always right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
PermutedDimsArray
at least does implementfunctor
, but you can always find an array wrapper which hasn't. Perhaps then the check should beisleaf
instead? Theisbits
check is still useful either way.Edit: I suppose
isnumeric
makes more sense since it forwards toisleaf
already andsetup
guarantees only unfamiliar immutable wrappers of immutable arrays will get their ownLeaf
. Moving theisbits
check up front also seems safe and could save a couple cycles on dict lookups.It's likely this can be simplified, but I wanted to get something on the page first in case there are any unforeseen edge cases present in this formulation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think anything
isnumeric
should have a correspondingLeaf
and hit the_update!(::Leaf, x; ...)
method.This one wants only to deal with mutable non-leaf things, like my
mutable struct MutTwo
example. Which makes me think thatismutable
is fine -- we haveFoo(MutTwo(Bar(Transpose(Array
, then the Array is leaf, and the only level at which it's worthwhile for this method to cache anything is theMutTwo
one. If this whole stack appears twice, a fresh newstruct Foo
cannot be distinguished from the old one.