-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SparseDiffTools extension * Remove Manifest --------- Co-authored-by: adrhill <[email protected]>
- Loading branch information
Showing
7 changed files
with
72 additions
and
1,204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
*.jl.cov | ||
*.jl.mem | ||
/Manifest.toml | ||
/test/Manifest.toml | ||
/docs/Manifest.toml | ||
/docs/build/ |
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,35 @@ | ||
module SparseConnectivityTracerSparseDiffToolsExt | ||
|
||
using SparseConnectivityTracer: connectivity | ||
using SparseDiffTools: | ||
AbstractSparseADType, | ||
AbstractSparsityDetection, | ||
ArrayInterface, | ||
GreedyD1Color, | ||
JacPrototypeSparsityDetection, | ||
SparseDiffTools | ||
|
||
Base.@kwdef struct ConnectivityTracerSparsityDetection{ | ||
A<:ArrayInterface.ColoringAlgorithm | ||
} <: AbstractSparsityDetection | ||
alg::A = GreedyD1Color() | ||
end | ||
|
||
function (alg::ConnectivityTracerSparsityDetection)( | ||
ad::AbstractSparseADType, f, x; fx=nothing, kwargs... | ||
) | ||
fx = fx === nothing ? similar(f(x)) : dx | ||
J = connectivity(f, x) | ||
_alg = JacPrototypeSparsityDetection(J, alg.alg) | ||
return _alg(ad, f, x; fx, kwargs...) | ||
end | ||
|
||
function (alg::ConnectivityTracerSparsityDetection)( | ||
ad::AbstractSparseADType, f!, fx, x; kwargs... | ||
) | ||
J = connectivity(f!, fx, x) | ||
_alg = JacPrototypeSparsityDetection(J, alg.alg) | ||
return _alg(ad, f!, fx, x; kwargs...) | ||
end | ||
|
||
end |
Oops, something went wrong.