JuliaDiff / JuliaDiff/ChainRulesCore.jl
Destination flipping for `add!!(x, y)`
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 267
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Right now add!!(x, y) will only ever mutate x, never y.
because of the logically linear nature of AD, y being a differential (i.e. the output of pullback) means it is used exactly once .
Which means we are infact free to mutate it, also since this will be it's only use. (same also says why we are always ok to mutate x)
See https://github.com/google-research/dex-lang/issues/401#issuecomment-756996758
(and to a lesser extent https://twitter.com/oxinabox_frames/status/1387722380978622468)
So we could pick either x or y depending on which was a valid inplacable_destination.
And maybe also always chose Array if one of them is an Array (since that is the best destination if that has been allocated)
This would solve at least the basic cases of #345
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the add!!(x, y) implementation and the inplacable_destination checks first. Compare how x and y are handled, then validate destination selection against the basic cases referenced by #345, including the Array preference if that behavior is adopted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend-api-design, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100