JuliaDiff / JuliaDiff/ChainRulesCore.jl
+(::AbstractThunk, ::InplaceableThunk) should use inplace
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 267
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Normal + between InplaceableThunk and anything else uses unthunk on the , InplaceableThunk and then +.
Because we don't want to mutate an input we were provided.
But in the case of the other input being a thunk of some kind, when know that when we unthunk that to do + we are getting a brand new value*
thus any change to it will not be visible as it didn't exist before this.
So we can use add!!(unthunk(other), inplaceable) instead of
+(unthunk(other), unthunk(inplaceable)).
Similar for the other argument order.
(* Assuming the think isn't just @thunk x which it shouldn't be since that is a waste of time. It needs to do some computation, which means we will not get an aliased results. Maybe exceptions apply to this if the work was done kind of reordering? The work will be a linear operation what ever it is.)
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
Locate the +(::AbstractThunk, ::InplaceableThunk) methods and the related add!! and unthunk entry points. Compare both argument orders, then run the existing arithmetic or thunk tests; done means both cases use the intended inplace path without mutating the provided input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100