Enzyme
Enzyme copied to clipboard
Add __*_finite versions of derivatives
From my understanding, the __*_finite versions of math functions are either aliases to the normal ones or faster versions that can assume no infinite operands. This automatically generates the same derivatives for them as the normal function.
@wsmoses How do you think we should handle this? Currently it would also generate derivatives for ___nv_asin_finite
for example, which doesn't exist.
We could either have separate fields for names we want to generate __*_finite
versions for, and ones that we don't. Or we could leave it as is and assume people would not define custom functions with names such as ___nv_asin_finite
Slightly generalizing, maybe we could add a "suffixof" tablegen command. Specifically since this same dupliaction also is required for cos, cosf, cosl,etc.
So maybe something like here https://github.com/EnzymeAD/Enzyme/blob/5468479e8f3de4658205751d42a6fbe073487e2e/enzyme/Enzyme/InstructionDerivatives.td#L335
but now
SameTypesSuffixFunc<"tanh", "cosh">
which will take the actual name of the function (tanhf), and remplace the prefix tanh with cosh.