Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules for builtins and intrinsics #208

Open
yebai opened this issue Jul 31, 2024 · 1 comment
Open

Rules for builtins and intrinsics #208

yebai opened this issue Jul 31, 2024 · 1 comment
Labels
enhancement New feature or request perpetual This issue is used to track an ongoing problem that cannot ever be fully resolved.

Comments

@yebai
Copy link
Contributor

yebai commented Jul 31, 2024

#206 and #203 added additional rules for missing builtin functions (lowest level primitives in Tapir). It would be helpful to know what other builtins lack rules and what would be required to support them all.

In addition, is it possible to organise builtin rules by Julia's version and include them conditionally? This would be helpful for #180.

@yebai yebai added the enhancement New feature or request label Jul 31, 2024
@willtebbutt
Copy link
Member

willtebbutt commented Jul 31, 2024

A Note To Those Directed Here By An Error

If you were directed here by an error indicates that something is going wrong with in the interaction between this package and one of Julia's builtins / intrinsics, please leave a comment. Please copy + paste your stack trace, and provide a MWE if possible so that we can easily reproduce the problem.

Context: there are a number of simple builtins / intrinsics in Julia which must have rules associated to them in order to differentiate them. At any given point in time, we should have rules for the vast majority of them, but probably won't have rules for all of them (they can change in non-breaking releases of Julia because they are not part of the public-facing interface, and there are some builtins / intrinsics that we just have not gotten around to implementing rules for yet because we have not found an example of them being used).

All this is to say that it's normally quite straightforward for us to add a rule which supports a given builtin / intrinsic, and we're very keen to resolve such issues as soon as we become aware of them.

My Original Reply to yebai

#206 and #203 added additional rules for missing builtin functions (lowest level primitives in Tapir). It would be helpful to know what other builtins lack rules and what would be required to support them all.

These are all documented inline with the code in the src/rrules/builtins.jl file. In particular, I would suggest taking a look at the function https://github.com/compintell/Tapir.jl/blob/b95d487095319e9b37ce94069858578553152d2f/src/rrules/builtins.jl#L713 , which makes it pretty clear what's there and what's not. There are also comments throughout the file (all builtins / intrinsics are listed in alphabetical order).

In addition, is it possible to organise builtin rules by Julia's version and include them conditionally? This would be helpful for #180.

Yes, and we're going to have to do something like this in order to maintain support for 1.10 once we start to support 1.11. Something like

@static if VERSION >= v1.11
function rrule!!(...)
...
end
end

etc should do it when we identify functions which only exist on specific versions.
In terms of ordering: they don't change very much from version-to-version, so I think it's just best to keep them in alphabetical order, and to conditionally include them depending on the version.

@willtebbutt willtebbutt changed the title Add rules for all builtin functions. Rules for builtins and intrinsics Aug 7, 2024
@willtebbutt willtebbutt added the perpetual This issue is used to track an ongoing problem that cannot ever be fully resolved. label Aug 7, 2024
@willtebbutt willtebbutt mentioned this issue Aug 7, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request perpetual This issue is used to track an ongoing problem that cannot ever be fully resolved.
Projects
None yet
Development

No branches or pull requests

2 participants