Skip to content

Commit

Permalink
Clarify use cases for DuplicatedNoNeed (#1753)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwe authored Aug 25, 2024
1 parent b9be0ac commit 0f7dfcc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/EnzymeCore/src/EnzymeCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ end
Like [`Duplicated`](@ref), except also specifies that Enzyme may avoid computing
the original result and only compute the derivative values.
This should only be used if `x` is a write-only variable. Otherwise, if the differentiated
function stores values in `x` and reads them back in subsequent computations, using
`DuplicatedNoNeed` may result in incorrect derivatives. In particular, `DuplicatedNoNeed`
should not be used for preallocated workspace, even if the user might not care about its
final value, as marking a variable as NoNeed means that reads from the variable are now
undefined.
"""
struct DuplicatedNoNeed{T} <: Annotation{T}
val::T
Expand Down

0 comments on commit 0f7dfcc

Please sign in to comment.