-
Notifications
You must be signed in to change notification settings - Fork 5
add AD (Enzyme) support via EnzymeExt #129
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
Closed
Changes from all commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
ce097f6
Add JacobianMethod types
mikeingold 3decf9f
Change JacobianMethod to DifferentiationMethod
mikeingold bd54b31
Add a third argument to jacobian for DiffMethod for dispatch
mikeingold 4cb6b02
Remove dead line
mikeingold 34fbca2
Remove obsolete analytic jacobian for BezierCurve
mikeingold 7e5a405
Add default step size if unspecified
mikeingold f17f326
Convert differential to three-argument with default FiniteDiff method
mikeingold ac23e43
Bigfix
mikeingold ceca1b5
Add two-arg Jacobian pointing to FD
mikeingold 2e7b23f
Apply formatting suggestion
mikeingold bfab883
Apply suggestion
mikeingold 62d7a53
Add a dt argument
mikeingold 3114e54
Update docstring API
mikeingold 3f0df9a
Add dt kwargs
mikeingold 8d7753d
Add missing params
mikeingold 855f3a9
Add dt kwargs (with TODOs)
mikeingold d832b05
Consolidate kwarg naming
mikeingold 6935da6
Update src/differentiation.jl
mikeingold bfcd204
Add exports
mikeingold 80b05f9
Tweak suggested naming [skip CI]
mikeingold 323c5d0
Update Line methods to use an internal differential method
mikeingold 25ce37d
Bump version to v0.16.0-DEV
mikeingold 78c3562
Add block for DifferentiationMethods
mikeingold 855d6c6
Drop abstract type
mikeingold 109193c
Add diff_method arguments
mikeingold 7321961
Change dt to diff_method
mikeingold 0a60af5
Merge branch 'main' into diff-select
mikeingold 8bd3a3d
Prepare to revert jacobian of BezierCurve (pending new benchmarks)
mikeingold e97d294
Bump CI
mikeingold 7afb39c
Add BézierCurve to benchmarks (#124) (#126)
mikeingold 7bde0f5
Merge branch 'main' into diff-select
JoshuaLampert eba102b
Reduce scald
mikeingold f5a75b8
Activate specialized Jacobian
mikeingold 3c93aa5
Define an Analytic method and update jacobian of Bezier to it
mikeingold 823b56b
Typo [skip CI]
mikeingold f5c1245
Typo
mikeingold d21b65a
Update src/specializations/BezierCurve.jl
mikeingold 19e0466
Implement has_analytic
mikeingold 60db456
Bugfix
mikeingold 136ff9d
Enable analytical for BezierCurve [skip CI]
mikeingold 88b1149
Implement default_method
mikeingold 0da8b4d
Fix arg definition
mikeingold 74cb3e1
Update arg type
mikeingold 617a1b1
Add methods on instances and types
mikeingold 4117374
Add tests for DifferentiationMethods
mikeingold bda9f3a
Use default_method in _integral methods
mikeingold 30d3f0b
Use default_method in Bezier methods, improve docstring
mikeingold a068fd4
Improve docstrings
mikeingold 5b8b283
Explicit namespace for test of non-exported function
mikeingold 42620d4
Fix typo
mikeingold 969ac40
Fix copy/paste error
mikeingold f22e165
Add tests for default_method
mikeingold 2699322
Type vs instance
mikeingold e8ab198
Export Analytical
mikeingold 695d425
Typo
mikeingold b8e657e
Typo
mikeingold 36434c8
Merge branch 'diff-select' of github.com:JuliaGeometry/MeshIntegrals.…
mikeingold 655555a
Parameterize Bezier type
mikeingold 8da09fd
Apply suggestions from code review
mikeingold 8f52882
Redefine Line, Plane, and Ray specializations as Analytical
mikeingold 678e8cc
Redefine Triangle and Tetrahedron specializations as Analytical
mikeingold b0f4970
Merge branch 'diff-select' of github.com:JuliaGeometry/MeshIntegrals.…
mikeingold 1560ebf
Try new solution (cant dispatch on kwarg types)
mikeingold fee4d35
Add jacobian code sections
mikeingold 73f0b9a
Add guarantees
mikeingold 77c3697
Move new utilities to utils and rename with prefix underscore
mikeingold 94f18f5
Typo
mikeingold 1af6a60
Update tests
mikeingold 36a0426
Update name
mikeingold afbd927
Update function name
mikeingold a36b864
Update comment
mikeingold 6133589
Update name
mikeingold 06946a1
Add better docstrings
mikeingold cc31a29
Bugfix - error not actually thrown
mikeingold 45b509c
Split DifferentiationMethod into separate testitem
mikeingold e6c226f
Tweak include order
mikeingold fb6c370
Formatting changes
mikeingold 4db8280
Remove redundant docstrings
mikeingold 65db4f6
Add docstrings for Ring and Rope, update for Bezier
mikeingold 9225188
Apply suggestions from code review
mikeingold 63bc35e
(WIP) Add a new kwarg section under Usage
mikeingold 0e4db4b
Clarify Usage section
mikeingold 4930a2b
Formatting
mikeingold 6907489
Add a WIP differential forms explainer
mikeingold 2b462d1
Rename page and add some structure
mikeingold b00e92b
Add new page to directory
mikeingold e4937e2
Update index page with README contents
mikeingold 3ae0a8b
add EnzymeExt
kylebeggs d596ef7
clean up some imports and naming
kylebeggs 5a3d4ab
Tweak formatting and update ts type
mikeingold a04ecd4
edit tests to use different AD backends
kylebeggs 87028a6
remove nice user error message if Enzyme isn't loaded. There is some …
kylebeggs 8c2cd5e
combine test integral function wrappers in Setup
kylebeggs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # How it Works (Work in Progress) | ||
|
|
||
| This page will explain how this package works by example... | ||
|
|
||
| Let $f$ be a function to be integrated throughout the volume bounded by a unit sphere. This integral is often expressed as simply | ||
| ```math | ||
| \iiint f(x, y, z) ~ \text{d}V | ||
| ``` | ||
|
|
||
| ## Parametric Functions | ||
|
|
||
| **!TODO! update segment to Ball** | ||
|
|
||
| Every supported `Meshes.Geometry` type is defined as having a parametric function that maps from a local coordinate system to every point on the geometry. For example, | ||
| ```julia | ||
| a = Meshes.Point(0, 0) | ||
| b = Meshes.Point(2, 4) | ||
| segment = Meshes.Segment(a, b) | ||
| ``` | ||
| defines a line segment beginning at point `a` and ending at point `b`. As a geometry with one parametric dimension (i.e. `paramdim(segment) == 1`), it can be treated as a function with one argument that returns a corresponding point on the segment. | ||
| ```julia | ||
| segment(0) == a | ||
| segment(0.5) == Point(1, 2) | ||
| segment(1) == b | ||
| ``` | ||
|
|
||
| ... where $t$ is a parametric coordinate used to generate points in the domain. | ||
|
|
||
|
|
||
|
|
||
| ## Differential Forms | ||
|
|
||
| Using differential forms, the general solution for integrating a geometry with three parametric dimensions ($t_1$, $t_2$, and $t_3$) is | ||
| ```math | ||
| \iiint f(x, y, z) ~ \left\| \text{d}t_1 \wedge \text{d}t_2 \wedge \text{d}t_3 \right\| | ||
| ``` | ||
|
|
||
| Since `Meshes.Geometry`s parametric functions have arguments that are defined on the domain $[0,1]$, this is equivalent to | ||
| ```math | ||
| \int_0^1 \int_0^1 \int_0^1 f(x, y, z) ~ \left\| \text{d}t_1 \wedge \text{d}t_2 \wedge \text{d}t_3 \right\| | ||
| ``` | ||
|
|
||
| For every point in the integration domain where the integrand function is evaluated, the differential element $\text{d}t_1 \wedge \text{d}t_2$ is calculated using [the Jacobian](https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant) of the parametric function. For a two-dimensional surface this Jacobian consists of two vectors, each pointing in the direction that the parametric function's output point will move by changing each input argument. The differential element, then, is simply the magnitude of the exterior product of these vectors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module MeshIntegralsEnzymeExt | ||
|
|
||
| using MeshIntegrals: MeshIntegrals, AutoEnzyme | ||
| using Meshes: Meshes | ||
| using Enzyme: Enzyme | ||
|
|
||
| function MeshIntegrals.jacobian( | ||
| geometry::Meshes.Geometry, | ||
| ts::Union{AbstractVector{T}, Tuple{T, Vararg{T}}}, | ||
| ::AutoEnzyme | ||
| ) where {T <: AbstractFloat} | ||
| return Meshes.to.(Enzyme.jacobian(Enzyme.Forward, geometry, ts...)) | ||
| end | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.