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

use Enzyme make_zero #1054

Merged
merged 1 commit into from
Jun 6, 2024
Merged

Conversation

m-bossart
Copy link
Contributor

Uses Enzyme's make_zero util instead of manually zeroing out the derivative variable.
Needed for SciML/NonlinearSolve.jl#439 to make the Enzyme rule compatible with NonlinearProblem

@ChrisRackauckas ChrisRackauckas merged commit 1559b16 into SciML:master Jun 6, 2024
42 of 77 checks passed
for v in dres.u
v .= 0
end
dres = Enzyme.make_zero(dres)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisRackauckas this is incorrect.

It will not update the values of dres in place, instead allocating a new variable.

This will lead to correctness issues if the rule is called within a loop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a make_zero!(v) we can use?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet, but I'll start making one. We haven't historically seen too much of a need for and always gottena way with the broadcast to zero (like here). But obviously generic structs need generic zeros

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

Successfully merging this pull request may close these issues.

3 participants