Skip to content

Bring back store!, accumulate, and accumulate!? #113

Closed
@nickrobinson251

Description

@nickrobinson251

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(∂))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmutabilityFor issues relating to supporting mutabilitypending-clear-needWe are not certain we need this. So waiting for evidence to be presented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions