Closed
Description
We removed store!
in #110, but one day we might want something like that back.
Paraphrasing @willtebbutt's comment
Just as it's useful to have accumulate!(::Array, ::Array)
(i.e. add!
) to avoid accumulating differentials into a third array, it maybe useful to have store!
for storing the result into a pre-allocated array. E.g. If you're a reverse-mode AD like ReverseDiff, and store!
would allow you the option to pre-allocate all of the memory required for the forwards- and reverse- passes over a programme.
for ease of reference, the old code was
"""
store!(Δ, ∂)
Stores `∂`, in `Δ`, overwriting what ever was in `Δ` before.
potentially avoiding intermediate temporary allocations that might be
necessary for alternative approaches (e.g. `copyto!(Δ, extern(∂))`)
Like [`accumulate`](@ref) and [`accumulate!`](@ref), this function is intended
to be customizable for specific rules/input types.
See also: [`accumulate`](@ref), [`accumulate!`](@ref)
"""
store!(Δ, ∂) = materialize!(Δ, broadcastable(∂))