ADTypes.jl is a common system for implementing multi-valued logic for choosing which automatic differentiation library to use.
The current standard is to have a keyword argument with autodiff = true
or autodiff = false
.
However, boolean logic is not sufficient to be able to do all of the choices that are
required. For example for forward-mode AD there is ForwardDiff vs Enzyme, and thus true
is ambgiuous. As libraries begin to support more and more of these autodiff mechanisms
for their trade-offs, every library will have their own version of ChooseForwardDiff()
etc. which would be a mess. Hence ADTypes.jl giving a single set of shared types for this.
ADTypes.AutoForwardDiff()
is the way to do it.
If they were enums then they would not be dispatch type-level information. This is needed
for the internals of many of the packages to be type-stable because the choice of config
type is different per package, i.e. what needs to be cached in order to use everything in
a non-allocating manner.
Sure, give a PR to add it.