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

Introduce add!! #226

Merged
merged 6 commits into from
Oct 5, 2020
Merged

Introduce add!! #226

merged 6 commits into from
Oct 5, 2020

Conversation

oxinabox
Copy link
Member

@oxinabox oxinabox commented Oct 5, 2020

This closes #113
at least the most important part.
I don't think we need store!,
and it doesn't do multi-arg accumulation, on the basis that we can add that later, lets not gold-plate this with features we don't yet need.
We can open a follow up issue about that after this is merged

It is named accumulate!! after the BangBang.jl convention.
a suffix of !! means I might mute the input, or i might not, but i will return definately return the thing

@nickrobinson251
Copy link
Contributor

One ! not enough hype?

@nickrobinson251
Copy link
Contributor

the BangBang.jl convention.
a suffix of !! means I might mute the input, or i might not, but i will return definately return the thing

I don't see this convention documented this way (at least not so succinctly) in the BangBang.jl docs... I'm sure you're right about the convention, but i'd feel better if it were explained in the BangBang docs so we could point to it

@willtebbutt
Copy link
Member

This is nice.

Regarding naming: is there a reason we can't call this function add! or sum! or something? While accumulate!! does correctly convey the intuition that we're somehow combining a collection of (co)tangents, it doesn't naturally convey the idea that the particular way in which we're "accumulating" these objects is via addition.

@oxinabox
Copy link
Member Author

oxinabox commented Oct 5, 2020

I would be down with add!!, I will make that change.
Much better since it means it doesn't conflict with defination of accumulate exported by Base that does take an operation.

Going for add reather than sum as for sum it should take a vector to things to be summed, rather than discrete arguments

@tkf confirmed for me that this was the correct convention on Slack.

@oxinabox oxinabox changed the title Introduce accumulate!! Introduce add!! Oct 5, 2020
@oxinabox
Copy link
Member Author

oxinabox commented Oct 5, 2020

I am still calling the file accumulation.jl as that refers to gradient accumultion.
and if we want to bring back store! etc then that would also go here.

@nickrobinson251
Copy link
Contributor

straying away from this PR... should we have an issue to adopt !! naming convention throughoutt ChainRules? e.g. it;s apply here i think: https://github.com/JuliaDiff/ChainRules.jl/blob/master/src/rulesets/LinearAlgebra/utils.jl#L29-L36

Copy link
Contributor

@nickrobinson251 nickrobinson251 left a comment

Choose a reason for hiding this comment

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

some questions but either answer is fine, so LGTM

@test 16 == add!!(12, @thunk(2*2))
@test 16 == add!!(16, Zero())

@test 16 == add!!(16, DoesNotExist()) # Should this be an error?
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have/need an issue for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

we don't, I am not sure we need one yet.

@oxinabox
Copy link
Member Author

oxinabox commented Oct 5, 2020

should we have an issue to adopt !! naming convention throughoutt ChainRules? e.g. it;s apply here i think: https://github.com/JuliaDiff/ChainRules.jl/blob/master/src/rulesets/LinearAlgebra/utils.jl#L29-L36

That particular case should just be a call to add!!
I will change that and look for others

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.

Bring back store!, accumulate, and accumulate!?
3 participants