Open bear24rw opened 3 years ago
Integers are presently assumed to be inactive (and thus don't impact the derivative computation).
Allowing active integers is certainly something worth including as we add support for custom accumulations
I'm curious, is there a bigger application use of integers of the differentiable types you have in mind (I haven't been searching, but haven't seen one offhand so it would be helpful to understand).
Integers are presently assumed to be inactive (and thus don't impact the derivative computation).
I see, is this something that is "easily" switched on or is it a bigger feature that needs implementation?
I'm curious, is there a bigger application use of integers of the differentiable types you have in mind (I haven't been searching, but haven't seen one offhand so it would be helpful to understand).
My situation is I have a large existing algorithm that I would like to differentiate. The algorithm uses a mix of types and it would be ideal if I could differentiate it "as is".
I wonder if re-writing the types to floats/doubles inside of Enzyme would be a possible solution?
Re active integers, I think three things would need to be added:
A codebase that uses a mix of types may not actually use active integers, even if it uses integers as part of the computation. The reason for this is a float => integer cast representing a round/floor correctly has a derivative of 0 (or technically a delta function). Thus I'm a bit curious more some more info (also feel free to email me wmoses@mit.edu if that's preferable / you don't want to share globally on github).
Re your last question, rewriting the types to float/double, however, should probably just work.
Thanks for the details, I will pursue the second option of converting all types to doubles and see if that works for my applications.
Re-opening this issue to preserve active integer type support as being on the radar. I (and several other contributors) likely won't have time to add such support until after the SuperComputing conference deadline, but hopefully can return to this afterwards.
Moreover, it should be relatively easy to add support via LLVM's existing fixed point intrinsics (https://llvm.org/docs/LangRef.html#fixed-point-arithmetic-intrinsics).
The question then for your case would be much simpler, assuming you can modify your code to cause those intrinsics to be emitted.
Are integer types supported? I only get the expected answer for floats or doubles.
Correct answer with type 'float':
Incorrect answer with type `int':