Ability to force Const on EnzymeRules arguments
- Dominant language
- Julia
- Stars
- 586
- Forks
- 108
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 44
Description
As mentioned in https://github.com/SciML/DiffEqBase.jl/pull/927, Enzyme.jl is currently missing the ability to force const on some arguments of the rules system. In this case, `ODEProblem` is forced to change to a `mutable struct` even though we know that the arguments of this struct will not be differentiated. We know that the arguments of the struct will not be differentiated since the design of the function is done so that would be true. For this example, a prior function:
```julia
function solve(prob::DEProblem, args...; sensealg = nothing,
u0 = nothing, p = nothing, wrap = Val(true), kwargs...)
if sensealg === nothing && haskey(prob.kwargs, :sensealg)
sensealg = prob.kwargs[:sensealg]
end
u0 = u0 !== nothing ? u0 : prob.u0
p = p !== nothing ? p : prob.p
solve_up(prob, sensealg, u0, p, args...; kwargs...)
end
```
sets up the inner call on the values of what would be in the struct (`prob.u0` and `prob.p`) and and then in that inner function, `prob` just holds consts (`prob.f`, etc.) and the EnzymeRule is written on `solve_up`. However, because `prob` is an argument to this function that we cannot guarantee from the rule writing is `Const`, it must be made a `mutable struct`, even though we know its values are safe to not differentiate.
Contributor guide
Assessment
This issue has not been assessed yet.