Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Add internal reverse-mode rules for ranges
This is the second PR to fix EnzymeAD#274. It's separated as I think the forward mode one can just be merged no problem, and this one may take a little bit more time. The crux of why this one is hard is because of how Julia deals with malformed ranges. ``` Basically dret.val = 182.0:156.0:26.0, the 26.0 is not the true value. Same as julia> 10:1:1 10:1:9 ``` Because of that behavior, the reverse `dret` does not actually have the information as to what its final point is, and its length is "incorrect" as it's changed by the constructor. In order to "fix" the reverse, we'd want to swap the `step` to negative and then use the same start/stop, but that information is already lost so it cannot be fixed within the rule. You can see the commented out code that would do the fixing if the information is there, and without that we cannot get a correctly sized reversed range for the rule. But it's a bit puzzling to figure out how to remove that behavior. In Base Julia it seems to be done in the `function (:)(start::T, step::T, stop::T) where T<:IEEEFloat`, and as I showed in the issue, I can overload that function and the behavior goes away, but Enzyme's constructed range still has that truncation behavior, which means I missed spot or something. namespace ConfigWidth namespace namespace needs_primal namespace AugmentedReturn
- Loading branch information