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

ReverseDiff for derivatives of custom types? #194

Open
ramos opened this issue Feb 1, 2022 · 1 comment
Open

ReverseDiff for derivatives of custom types? #194

ramos opened this issue Feb 1, 2022 · 1 comment

Comments

@ramos
Copy link

ramos commented Feb 1, 2022

Hi,

I need to evaluate the gradient of a function with my custom type/operations. For example if f(x) = x^3, I want the derivative obtained with the usual rules of calculus (i.e. df(x)=3*x^2), to be evaluated for typeof(x) = foo. Of course I have pre-defined the operations *(a::Number,b::foo) and ^(a::foo,n::Integer), etc...

I know that Zygote can easily do this, but it is about an order of magnitude slower than ReverseDiff for my problem and Real inputs, so I would rather prefer to use a compiled tape and ReverseDiff.

Thanks,

@rejuvyesh
Copy link

I don't think ReverseDiff is designed for that. Your best bet is to convert your type into an array.

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