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

Parameter unpacking yields ERRORs #677

Closed
simsurace opened this issue Mar 15, 2023 · 3 comments
Closed

Parameter unpacking yields ERRORs #677

simsurace opened this issue Mar 15, 2023 · 3 comments

Comments

@simsurace
Copy link
Contributor

simsurace commented Mar 15, 2023

I have started trying out Enzyme.jl for some applications. A lot of things already seem to be working nicely!

This is a pattern that is used quite often to convert from named parameters to vectors and applying transformations for optimization (e.g. in ParameterHandling.jl). Here is a M(n)WE:

using Enzyme

f(par::NamedTuple) = par.a * par.b + par.c
par = (a = 1., b = 2., c = 3.)
autodiff(Reverse, f, Active(par)) # works beautifully and efficiently

unpack_vector(vec::Vector) = (a = vec[1], b = vec[2], c = vec[3])
vec = [1., 2., 3.]
autodiff(Reverse, f  unpack_vector, Active(vec)) # ERROR: Conversion of boxed type Vector{Float64} is not allowed

In a slightly different example, sometimes the error reads ERROR: Duplicated Returns not yet handled.

@wsmoses
Copy link
Member

wsmoses commented Mar 15, 2023

You need to use duplicated for arrays

@wsmoses wsmoses closed this as completed Mar 15, 2023
@theogf
Copy link

theogf commented Mar 15, 2023

Is there a way to catch this error and to return a more informative message?

@wsmoses
Copy link
Member

wsmoses commented Mar 15, 2023

Agreed (#318), PR's welcome :)

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

3 participants