Conversation
It wasn't, I couldn't figure out how to make it work. So for now we've required that if someone has preallocated caches, then they have to choose ForwardDiff or Enzyme and cannot support both. I asked @wsmoses if there was some way so that the extra caches from here somehow hook in, or worst case scenario if they are just ignored so the code is compatible, that is fine. But there has always been the issues with But if you've got a way to get around this, that's great! |
This PR makes at least example 1 from the readme work in forward mode. I believe the only true issue is Do you have any more interesting corner cases, I could throw at this? |
|
I think the two cases are either putting the cache in |
What feature report was addressed?
We are evaluating the use of PreallocationTools for Trixi, but need to ensure that adding it does not break Enzyme support.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Enzyme requires the shadow heap values to have the same type and shape as the primals. Therefore
dual_ducan actually be smaller than with ForwardDiff.Supporting Enzyme batch mode is only possible on
v1.11or by allocating memory / doing unsafe operations.My biggest worry would be user who attempt to use
Enzymeover ForwardDiff. Then in the case ofConst(stod)Enzyme and ForwardDiff would compete for the same memory.The case of
Duplicated(stod, Enzyme.make_zero(stod))does the right thing in this instance.