-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Symbol -> AbstractADType mapping (#62)
- Loading branch information
Showing
6 changed files
with
60 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" | |
authors = [ | ||
"Vaibhav Dixit <[email protected]>, Guillaume Dalle and contributors", | ||
] | ||
version = "1.3.0" | ||
version = "1.4.0" | ||
|
||
[deps] | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
|
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,29 @@ | ||
""" | ||
ADTypes.Auto(package::Symbol) | ||
A shortcut that converts an AD package name into an instance of [`AbstractADType`](@ref), with all parameters set to their default values. | ||
!!! warning | ||
This function is type-unstable by design and might lead to suboptimal performance. | ||
In most cases, you should never need it: use the individual backend types directly. | ||
# Example | ||
```jldoctest | ||
import ADTypes | ||
backend = ADTypes.Auto(:Zygote) | ||
# output | ||
ADTypes.AutoZygote() | ||
``` | ||
""" | ||
Auto(package::Symbol, args...; kws...) = Auto(Val(package), args...; kws...) | ||
|
||
for backend in (:ChainRules, :Diffractor, :Enzyme, :FastDifferentiation, | ||
:FiniteDiff, :FiniteDifferences, :ForwardDiff, :PolyesterForwardDiff, | ||
:ReverseDiff, :Symbolics, :Tapir, :Tracker, :Zygote) | ||
@eval Auto(::Val{$(QuoteNode(backend))}, args...; kws...) = $(Symbol(:Auto, backend))(args...; kws...) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using ADTypes | ||
using Test | ||
|
||
@test ADTypes.Auto(:ChainRules, 1) isa AutoChainRules{Int64} | ||
@test ADTypes.Auto(:Diffractor) isa AutoDiffractor | ||
@test ADTypes.Auto(:Enzyme) isa AutoEnzyme | ||
@test ADTypes.Auto(:FastDifferentiation) isa AutoFastDifferentiation | ||
@test ADTypes.Auto(:FiniteDiff) isa AutoFiniteDiff | ||
@test ADTypes.Auto(:FiniteDifferences, 1.0) isa AutoFiniteDifferences{Float64} | ||
@test ADTypes.Auto(:ForwardDiff) isa AutoForwardDiff | ||
@test ADTypes.Auto(:PolyesterForwardDiff) isa AutoPolyesterForwardDiff | ||
@test ADTypes.Auto(:ReverseDiff) isa AutoReverseDiff | ||
@test ADTypes.Auto(:Symbolics) isa AutoSymbolics | ||
@test ADTypes.Auto(:Tapir) isa AutoTapir | ||
@test ADTypes.Auto(:Tracker) isa AutoTracker | ||
@test ADTypes.Auto(:Zygote) isa AutoZygote | ||
|
||
@test_throws MethodError ADTypes.Auto(:ThisPackageDoesNotExist) | ||
@test_throws UndefKeywordError ADTypes.Auto(:ChainRules) | ||
@test_throws UndefKeywordError ADTypes.Auto(:FiniteDifferences) |
72f806d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
72f806d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/109228
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: