-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de0a32d
commit 6f3abb8
Showing
17 changed files
with
975 additions
and
735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
struct AbstractDiffFunction{F, B} <: Function | ||
f::F | ||
backend::B | ||
end | ||
ForwardDiffFunction(f) = AbstractDiffFunction(f, AD.ForwardDiffBackend()) | ||
(f::AbstractDiffFunction)(x) = f.f(x) | ||
function ChainRulesCore.rrule( | ||
f::AbstractDiffFunction, x::AbstractVector, | ||
) | ||
v, (∇,) = AbstractDifferentiation.value_and_jacobian(f.backend, f.f, x) | ||
return v, Δ -> (NoTangent(), ∇' * Δ) | ||
end | ||
function ChainRulesCore.frule( | ||
(_, Δx), f::AbstractDiffFunction, x::AbstractVector, | ||
) | ||
v, (∇,) = AbstractDifferentiation.value_and_jacobian(f.backend, f.f, x) | ||
return v, ∇ * Δx | ||
end | ||
@ForwardDiff_frule (f::AbstractDiffFunction)(x::AbstractVector{<:ForwardDiff.Dual}) |
Oops, something went wrong.