-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add AD (Enzyme) support via MeshIntegralsEnzymeExt (#152)
* add Enzyme as a potential differentiation method for the jacobian * refactor check for enzyme support * add FP to _default_diff_method * add `using Enzyme` to benchmarks.jl * update CoordRefSystems.jl compat Co-authored-by: Joshua Lampert <[email protected]> * add Enzyme to Benchmark Project.toml * fix Meshes compat in Benchmark Project.toml Co-authored-by: Joshua Lampert <[email protected]> * use import Enzyme, not using Enzyme Co-authored-by: Joshua Lampert <[email protected]> * fix typo in Benchmarks Project.toml * remove Meshes version check in combinations.jl * Apply format suggestion Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/Project.toml Co-authored-by: Joshua Lampert <[email protected]> * Bump compat of Enzyme to v0.13.19 * test supports_autoenzyme to combinations; test both backends for wrong dims * Restore recently-updated FiniteDifference constructors * Add docstrings, formatting * Formatting * Add test for two-arg jacobian * Use rest of MeshIntegrals namespace * Disambiguate use of jacobian * fix test * use `import Enzyme` Co-authored-by: Joshua Lampert <[email protected]> * use `import Enzyme` Co-authored-by: Joshua Lampert <[email protected]> * remove unneeded MeshIntegrals.jl Co-authored-by: Joshua Lampert <[email protected]> --------- Co-authored-by: Joshua Lampert <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Michael Ingold <[email protected]>
- Loading branch information
1 parent
c7c0a47
commit 969ee0a
Showing
15 changed files
with
175 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
[deps] | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa" | ||
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" | ||
|
||
[compat] | ||
BenchmarkTools = "1.5" | ||
Enzyme = "0.13.19" | ||
LinearAlgebra = "1" | ||
Meshes = "0.50, 0.51, 0.52" | ||
Meshes = "0.51.20, 0.52" | ||
Unitful = "1.19" | ||
julia = "1.9" |
This file contains 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 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,19 @@ | ||
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} | ||
Dim = Meshes.paramdim(geometry) | ||
if Dim != length(ts) | ||
throw(ArgumentError("ts must have same number of dimensions as geometry.")) | ||
end | ||
return Meshes.to.(Enzyme.jacobian(Enzyme.Forward, geometry, ts...)) | ||
end | ||
|
||
end |
This file contains 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 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 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 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 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 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 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.