-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix pretty printing and ReverseDiff constructor #67
Conversation
Code import ADTypes
struct FakeSparsityDetector <: ADTypes.AbstractSparsityDetector end
struct FakeColoringAlgorithm <: ADTypes.AbstractColoringAlgorithm end
for backend in [
# dense
ADTypes.AutoChainRules(; ruleconfig = :rc),
ADTypes.AutoDiffractor(),
ADTypes.AutoEnzyme(),
ADTypes.AutoEnzyme(mode = :forward),
ADTypes.AutoFastDifferentiation(),
ADTypes.AutoFiniteDiff(),
ADTypes.AutoFiniteDiff(fdtype = :fd, fdjtype = :fdj, fdhtype = :fdh),
ADTypes.AutoFiniteDifferences(; fdm = :fdm),
ADTypes.AutoForwardDiff(),
ADTypes.AutoForwardDiff(chunksize = 3, tag = :tag),
ADTypes.AutoPolyesterForwardDiff(),
ADTypes.AutoPolyesterForwardDiff(chunksize = 3, tag = :tag),
ADTypes.AutoReverseDiff(),
ADTypes.AutoReverseDiff(compile = true),
ADTypes.AutoSymbolics(),
ADTypes.AutoTapir(),
ADTypes.AutoTapir(safe_mode = false),
ADTypes.AutoTracker(),
ADTypes.AutoZygote(),
# sparse
ADTypes.AutoSparse(ADTypes.AutoForwardDiff()),
ADTypes.AutoSparse(
ADTypes.AutoForwardDiff();
sparsity_detector = FakeSparsityDetector(),
coloring_algorithm = FakeColoringAlgorithm()
)
]
println(backend)
end Before (1.5.1) (note the unpredictable presence of the package name) AutoChainRules(ruleconfig=:rc)
ADTypes.AutoDiffractor()
AutoEnzyme()
AutoEnzyme(mode=:forward)
ADTypes.AutoFastDifferentiation()
AutoFiniteDiff()
AutoFiniteDiff(fdtype=:fd, fdjtype=:fdj, fdhtype=:fdh)
AutoFiniteDifferences(fdm=:fdm)
AutoForwardDiff()
AutoForwardDiff(chunksize=3, tag=:tag)
AutoPolyesterForwardDiff()
AutoPolyesterForwardDiff(chunksize=3, tag=:tag)
AutoReverseDiff()
AutoReverseDiff(compile=true)
ADTypes.AutoSymbolics()
AutoTapir()
AutoTapir(safe_mode=false)
ADTypes.AutoTracker()
ADTypes.AutoZygote()
AutoSparse(dense_ad=AutoForwardDiff())
AutoSparse(dense_ad=AutoForwardDiff(), sparsity_detector=FakeSparsityDetector(), coloring_algorithm=FakeColoringAlgorithm()))
After (this PR, 1.5.2) ADTypes.AutoChainRules(ruleconfig=:rc)
ADTypes.AutoDiffractor()
ADTypes.AutoEnzyme()
ADTypes.AutoEnzyme(mode=:forward)
ADTypes.AutoFastDifferentiation()
ADTypes.AutoFiniteDiff()
ADTypes.AutoFiniteDiff(fdtype=:fd, fdjtype=:fdj, fdhtype=:fdh)
ADTypes.AutoFiniteDifferences(fdm=:fdm)
ADTypes.AutoForwardDiff()
ADTypes.AutoForwardDiff(chunksize=3, tag=:tag)
ADTypes.AutoPolyesterForwardDiff()
ADTypes.AutoPolyesterForwardDiff(chunksize=3, tag=:tag)
ADTypes.AutoReverseDiff()
ADTypes.AutoReverseDiff(compile=true)
ADTypes.AutoSymbolics()
ADTypes.AutoTapir()
ADTypes.AutoTapir(safe_mode=false)
ADTypes.AutoTracker()
ADTypes.AutoZygote()
ADTypes.AutoSparse(dense_ad=ADTypes.AutoForwardDiff())
ADTypes.AutoSparse(dense_ad=ADTypes.AutoForwardDiff(), sparsity_detector=FakeSparsityDetector(), coloring_algorithm=FakeColoringAlgorithm()) |
print(io, "fdtype=", repr(backend.fdtype; context = io), ", ") | ||
backend.fdjtype != backend.fdtype && | ||
print(io, "fdjtype=", repr(backend.fdjtype; context = io), ", ") | ||
backend.fdhtype != Val(:hcentral) && | ||
print(io, "fdhtype=", repr(backend.fdhtype; context = io)) |
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.
These don't show the Val?
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.
Yes they do, there's just no Val
in the test case I displayed above. Take a look here:
julia> string(AutoFiniteDiff(fdjtype=Val(:whatever)))
"AutoFiniteDiff(fdjtype=Val{:whatever}(), )"
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.
@ChrisRackauckas I think this one is a strict improvement over the current state, what do you say?
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.
LGTM
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Fix #65 and #66
Should we test the round-trip-ability of these printings by parsing the string back into an object?