The DiffResults documentation clearly states that whenever a DiffResult object is used, it must be realiased at the end of the function call:
result = do_stuff!(result, args...)
See for instance the docstrings in https://juliadiff.org/DiffResults.jl/stable/#Mutating-a-DiffResult, or the issue DiffResults#17
This is not done by ReverseDiff, for instance here:
|
function gradient(f, input, cfg::GradientConfig = GradientConfig(input)) |
|
tape = GradientTape(f, input, cfg) |
|
result = construct_result(input_hook(tape)) |
|
seeded_reverse_pass!(result, tape) |
|
empty!(cfg.tape) |
|
return result |
|
end |
Am I right in deducing that it can lead to incorrectness?
The DiffResults documentation clearly states that whenever a
DiffResultobject is used, it must be realiased at the end of the function call:See for instance the docstrings in https://juliadiff.org/DiffResults.jl/stable/#Mutating-a-DiffResult, or the issue DiffResults#17
This is not done by ReverseDiff, for instance here:
ReverseDiff.jl/src/api/gradients.jl
Lines 21 to 27 in c982cde
Am I right in deducing that it can lead to incorrectness?