Closed
Description
As mentioned at #180 (comment), when a function contains a call to ``adjoint`, ReverseDiff (with latest dependencies) gives a gradient that differs from other AD packages:
This is an MWE:
using ForwardDiff, ReverseDiff
using LinearAlgebra: norm
f(x) = sum(x' .* x)
x = rand(5)
test = ForwardDiff.gradient!(DiffResults.GradientResult(x), f, x)
@show DiffResults.gradient(test)
seedx = rand(eltype(x), size(x))
tp = ReverseDiff.GradientTape(f, seedx)
@show ReverseDiff.gradient!(tp, x)
Run it on the master branch of ReverseDiff, and ForwardDiff=0.10.18, DiffRules=1.0.2, the two results will be the same.
Run it on the master branch of ReverseDiff, and ForwardDiff=0.10.19, DiffRules=1.3.0, the two results will be different.
The problem was found after DiffRules added these two rules lately:
@define_diffrule Base.conj(x) = :( 1 )
@define_diffrule Base.adjoint(x) = :( 1 )
Metadata
Metadata
Assignees
Labels
No labels