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

frule_via_ad should accept several arguments #12

Open
gdalle opened this issue Mar 13, 2023 · 5 comments
Open

frule_via_ad should accept several arguments #12

gdalle opened this issue Mar 13, 2023 · 5 comments

Comments

@gdalle
Copy link
Contributor

gdalle commented Mar 13, 2023

According to the official API specification of ChainRulesCore.jl, frule_via_ad should accept all the arguments of the function as a destructured tuple: https://juliadiff.org/ChainRulesCore.jl/stable/api.html#ChainRulesCore.frule_via_ad

However, it seems that ForwardDiffChainRules.jl only accepts one argument:

function ChainRulesCore.frule_via_ad(
config::ForwardDiffRuleConfig,
tangent,
f,
f_arg;
kwargs...,
)

I think this is the reason for a bug in my code. Do you think it is fixable?

@gdalle
Copy link
Contributor Author

gdalle commented Mar 14, 2023

@mohamed82008 any idea?

@mohamed82008
Copy link
Collaborator

Not a fan of supporting multiple arguments with ForwardDiff. ForwardDiff's API does not support that.

@mohamed82008
Copy link
Collaborator

hmm on second thought, I changed my mind

@gdalle
Copy link
Contributor Author

gdalle commented Mar 16, 2023

Given the metaprogramming-heavy nature of this package, I'm not sure how to make a PR implementing this

@mohamed82008
Copy link
Collaborator

NonconvexUtils already supports this https://github.com/JuliaNonconvex/NonconvexUtils.jl/blob/main/src/forwarddiff_frule.jl#L1. You can just assume the inputs are all real/arrays and not recursive containers and simplify the implementation. I use flatten/unflatten but that's because I wanted to be too generic. No need to be that generic.

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