Closed
Description
Is it expected that all packages that implement the interface use AD.@primitive
? e.g., ForwardDiff can use DiffResults to enable returning a value and a gradient and/or hessian. In cases like this, what is advised?
I can see a few possibilities:
- define
@primitive pushforward_function(...)
only to keep things simple - define
@primitive pushforward_function(...)
but then overload methods likevalue_and_gradient
for which the AD package has a more efficient approach. - implement all necessary interface methods by hand
Edit: I'm guessing (2) is the preferred option? For many (most? all?) AD engines, the fallback to working in terms of jacobians will be much less efficient than overloading the corresponding methods.