Enzyme gradients
Loading Enzyme registers the rule of every operator as an Enzyme reverse-mode rule, so Enzyme is one of the backends. Use reverse mode:
julia
using ComposableRecurrences, Enzyme
using DifferentiationInterface: AutoEnzyme, gradient
backend = AutoEnzyme(; mode = Enzyme.Reverse)
r = Recurrence([0.5, 0.3])
loss(R) = sum(r(R; history = [1.0, 1.0]))
round.(gradient(loss, backend, fill(1.1, 4)); digits = 3)
# output
4-element Vector{Float64}:
2.17
1.615
1.04
0.613Reverse mode through an operator's rule needs no runtime activity; forward mode and calls that take plain AD do.
Enzyme's place among the other backends is in Backends.
All extensions are listed in the overview.