|
1 | 1 | using BenchmarkTools, LinearSolve, NonlinearSolve, StaticArrays, Random, LinearAlgebra,
|
2 | 2 | Test, ForwardDiff, Zygote, Enzyme, SparseDiffTools, DiffEqBase
|
3 | 3 |
|
| 4 | +# Enzyme stalls on windows. Just swap it with something else |
| 5 | +function __autosparseenzyme() |
| 6 | + if Sys.iswindows() |
| 7 | + return AutoSparseFiniteDiff() |
| 8 | + else |
| 9 | + return AutoSparseEnzyme() |
| 10 | + end |
| 11 | +end |
| 12 | + |
4 | 13 | _nameof(x) = applicable(nameof, x) ? nameof(x) : _nameof(typeof(x))
|
5 | 14 |
|
6 | 15 | quadratic_f(u, p) = u .* u .- p
|
@@ -95,7 +104,7 @@ const TERMINATION_CONDITIONS = [
|
95 | 104 | @test nlprob_iterator_interface(quadratic_f!, p, Val(true)) ≈ sqrt.(p)
|
96 | 105 |
|
97 | 106 | @testset "ADType: $(autodiff) u0: $(_nameof(u0))" for autodiff in (AutoSparseForwardDiff(),
|
98 |
| - AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), AutoSparseEnzyme()), u0 in (1.0, [1.0, 1.0]) |
| 107 | + AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), __autosparseenzyme()), u0 in (1.0, [1.0, 1.0]) |
99 | 108 | probN = NonlinearProblem(quadratic_f, u0, 2.0)
|
100 | 109 | @test all(solve(probN, NewtonRaphson(; autodiff)).u .≈ sqrt(2.0))
|
101 | 110 | end
|
|
175 | 184 | @test nlprob_iterator_interface(quadratic_f!, p, Val(true)) ≈ sqrt.(p)
|
176 | 185 |
|
177 | 186 | @testset "ADType: $(autodiff) u0: $(_nameof(u0)) radius_update_scheme: $(radius_update_scheme)" for autodiff in (AutoSparseForwardDiff(),
|
178 |
| - AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), AutoSparseEnzyme()), u0 in (1.0, [1.0, 1.0]), |
| 187 | + AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), __autosparseenzyme()), u0 in (1.0, [1.0, 1.0]), |
179 | 188 | radius_update_scheme in radius_update_schemes
|
180 | 189 |
|
181 | 190 | probN = NonlinearProblem(quadratic_f, u0, 2.0)
|
|
279 | 288 | end
|
280 | 289 |
|
281 | 290 | @testset "ADType: $(autodiff) u0: $(_nameof(u0))" for autodiff in (AutoSparseForwardDiff(),
|
282 |
| - AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), AutoSparseEnzyme()), u0 in (1.0, [1.0, 1.0]) |
| 291 | + AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), __autosparseenzyme()), u0 in (1.0, [1.0, 1.0]) |
283 | 292 | probN = NonlinearProblem(quadratic_f, u0, 2.0)
|
284 | 293 | @test all(solve(probN, LevenbergMarquardt(; autodiff); abstol = 1e-9,
|
285 | 294 | reltol = 1e-9).u .≈ sqrt(2.0))
|
|
494 | 503 | @test nlprob_iterator_interface(quadratic_f!, p, Val(true)) ≈ sqrt.(p)
|
495 | 504 |
|
496 | 505 | @testset "ADType: $(autodiff) u0: $(_nameof(u0))" for autodiff in (AutoSparseForwardDiff(),
|
497 |
| - AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), AutoSparseEnzyme()), u0 in (1.0, [1.0, 1.0]) |
| 506 | + AutoSparseFiniteDiff(), AutoZygote(), AutoSparseZygote(), __autosparseenzyme()), u0 in (1.0, [1.0, 1.0]) |
498 | 507 | probN = NonlinearProblem(quadratic_f, u0, 2.0)
|
499 | 508 | @test all(solve(probN, PseudoTransient(; alpha_initial = 10.0, autodiff)).u .≈
|
500 | 509 | sqrt(2.0))
|
|
0 commit comments