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

fix: handle function contexts differently from constant contexts #660

Merged
merged 12 commits into from
Dec 6, 2024

Conversation

gdalle
Copy link
Member

@gdalle gdalle commented Dec 6, 2024

DI source

  • Define FunctionContext and BackendContext as private subtypes of Context, useful in second-order operators when passing stuff to the shuffled first-order operator
  • Add shortcut ConstantOrFunctionOrBackend = Union{Constant,FunctionContext,BackendContext}

DI extensions

  • Replace DI.Constant with DI.ConstantOrFunctionOrBackend in most places
  • ForwardDiff: define PrepContext internally for second-order preparation with the right Dual type
  • Enzyme: handle FunctionContext differently by annotating it as Duplicated if necessary. Function annotation doesn't work for second-order Enzyme #592 is still not fixed but at least it should error in the second order case.

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.60%. Comparing base (6806fef) to head (2186d82).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #660      +/-   ##
==========================================
+ Coverage   97.58%   97.60%   +0.01%     
==========================================
  Files         112      112              
  Lines        5551     5592      +41     
==========================================
+ Hits         5417     5458      +41     
  Misses        134      134              
Flag Coverage Δ
DI 98.75% <100.00%> (+0.01%) ⬆️
DIT 95.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gdalle gdalle merged commit 0f3d2c1 into main Dec 6, 2024
48 checks passed
@gdalle gdalle deleted the gd/more_contexts branch December 6, 2024 18:34
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.

1 participant