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

Supporting rules on functions with keyword arguments #617

Closed
vchuravy opened this issue Feb 8, 2023 · 3 comments
Closed

Supporting rules on functions with keyword arguments #617

vchuravy opened this issue Feb 8, 2023 · 3 comments

Comments

@vchuravy
Copy link
Member

vchuravy commented Feb 8, 2023

Might be easier for 1.8 now that it's just kwfunc, but we need an isapplicable check for kwfuncs....
Maybe a generic handler for kwfuncs...

ChainRules has some hints https://github.com/JuliaDiff/ChainRulesCore.jl/blob/ed9a0073ff83cb3b1f4619303e41f4dd5d8c4825/src/rules.jl#L75-L79

cc: @vtjnash and @oxinabox

@vchuravy
Copy link
Member Author

vchuravy commented Feb 8, 2023

x-ref: JuliaDiff/ChainRules.jl#656

@vchuravy
Copy link
Member Author

vchuravy commented Feb 8, 2023

I wrote up a short snippet for checking if we have a rule.

function has_frule_kw_from_sig(@nospecialize(TT); world=Base.get_world_counter())
    ft, tt = _annotate_tt(TT)
    kwfunc = Core.kwfunc(EnzymeCore.EnzymeRules.forward)
    TT = Tuple{<:Any, typeof(forward), <:Annotation{ft}, Type{<:Annotation}, tt...}
    isapplicable(kwfunc, TT; world)
end   

But that needs testing. I think the big question is for how this works on the LLVM level. E.g maybe we first need to check that we can diff through kwargs.

@wsmoses wsmoses closed this as completed Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants