-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BREAKING] Force use of
Tangents
in pushforward
, pullback
and `…
…hvp` (#455) * Force use of `Tangents` * Fix * Add `map` and other utilities * Add methods * Scenarios * Fixes * Fixes * Fix * Coverage and docs * Avoid duplicate imports * Map * Dix focs
- Loading branch information
Showing
54 changed files
with
437 additions
and
386 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,10 @@ DifferentiationInterface | |
|
||
## First order | ||
|
||
```@docs | ||
Tangents | ||
``` | ||
|
||
### Pushforward | ||
|
||
```@docs | ||
|
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
16 changes: 5 additions & 11 deletions
16
DifferentiationInterface/ext/DifferentiationInterfaceChainRulesCoreExt/differentiate_with.jl
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 |
---|---|---|
@@ -1,16 +1,10 @@ | ||
# forward mode unused for lack of implementations | ||
#= | ||
function ChainRulesCore.frule((_, dx), dw::DifferentiateWith, x) | ||
@compat (; f, backend) = dw | ||
y, dy = DI.value_and_pushforward(f, backend, x, dx) | ||
return y, dy | ||
end | ||
=# | ||
|
||
function ChainRulesCore.rrule(dw::DifferentiateWith, x) | ||
@compat (; f, backend) = dw | ||
y = f(x) | ||
extras_same = DI.prepare_pullback_same_point(f, backend, x, y) | ||
pullbackfunc(dy) = (NoTangent(), DI.pullback(f, extras_same, backend, x, dy)) | ||
extras_same = DI.prepare_pullback_same_point(f, backend, x, DI.Tangents(y)) | ||
function pullbackfunc(dy) | ||
tx = DI.pullback(f, extras_same, backend, x, DI.Tangents(dy)) | ||
return (NoTangent(), only(tx)) | ||
end | ||
return y, pullbackfunc | ||
end |
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
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
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
Oops, something went wrong.