diff --git a/Project.toml b/Project.toml index ae346348b..7802b1bd8 100644 --- a/Project.toml +++ b/Project.toml @@ -98,6 +98,7 @@ PETSc = "0.3" Pkg = "1.10" PrecompileTools = "1.2" Preferences = "1.4" +PolyesterForwardDiff = "0.1" Random = "1.10" ReTestItems = "1.24" Reexport = "1.2" @@ -138,6 +139,7 @@ NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141" OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a" PETSc = "ace2c81b-2b5f-4b1e-a30d-d662738edfe0" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" SIAMFANLEquations = "084e46ad-d928-497d-ad5e-07fa361a48c4" @@ -150,4 +152,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["Aqua", "BandedMatrices", "BenchmarkTools", "CUDA", "Enzyme", "ExplicitImports", "FastLevenbergMarquardt", "FixedPointAcceleration", "Hwloc", "InteractiveUtils", "LeastSquaresOptim", "LineSearches", "MINPACK", "NLSolvers", "NLsolve", "NaNMath", "NonlinearProblemLibrary", "OrdinaryDiffEqTsit5", "PETSc", "Pkg", "Random", "ReTestItems", "SIAMFANLEquations", "SparseConnectivityTracer", "SpeedMapping", "StableRNGs", "StaticArrays", "Sundials", "Test", "Zygote"] +test = ["Aqua", "BandedMatrices", "BenchmarkTools", "CUDA", "Enzyme", "ExplicitImports", "FastLevenbergMarquardt", "FixedPointAcceleration", "Hwloc", "InteractiveUtils", "LeastSquaresOptim", "LineSearches", "MINPACK", "NLSolvers", "NLsolve", "NaNMath", "NonlinearProblemLibrary", "OrdinaryDiffEqTsit5", "PETSc", "Pkg", "PolyesterForwardDiff", "Random", "ReTestItems", "SIAMFANLEquations", "SparseConnectivityTracer", "SpeedMapping", "StableRNGs", "StaticArrays", "Sundials", "Test", "Zygote"] diff --git a/lib/NonlinearSolveBase/Project.toml b/lib/NonlinearSolveBase/Project.toml index ae16dfd93..f35c949cf 100644 --- a/lib/NonlinearSolveBase/Project.toml +++ b/lib/NonlinearSolveBase/Project.toml @@ -1,7 +1,7 @@ name = "NonlinearSolveBase" uuid = "be0214bd-f91f-a760-ac4e-3421ce2b2da0" authors = ["Avik Pal and contributors"] -version = "1.3.0" +version = "1.3.1" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/lib/NonlinearSolveBase/src/autodiff.jl b/lib/NonlinearSolveBase/src/autodiff.jl index f70e9770b..c92a3e27d 100644 --- a/lib/NonlinearSolveBase/src/autodiff.jl +++ b/lib/NonlinearSolveBase/src/autodiff.jl @@ -124,6 +124,11 @@ function additional_incompatible_backend_check(prob::AbstractNonlinearProblem, end return hasbranching(prob.f, prob.u0, prob.p) end +function additional_incompatible_backend_check( + prob::AbstractNonlinearProblem, ::ADTypes.AutoPolyesterForwardDiff) + prob.u0 isa SArray && return true # promotes to a mutable array + return false +end is_finite_differences_backend(ad::AbstractADType) = false is_finite_differences_backend(::ADTypes.AutoFiniteDiff) = true diff --git a/test/core_tests.jl b/test/core_tests.jl index 301b0b389..289376c36 100644 --- a/test/core_tests.jl +++ b/test/core_tests.jl @@ -414,3 +414,16 @@ end solve(prob) @test sol.u≈[1.0, 0.25] atol=1e-3 rtol=1e-3 end + +@testset "No PolyesterForwardDiff for SArray" tags=[:core] begin + using StaticArrays, PolyesterForwardDiff + + f_oop(u, p) = u .* u .- p + + N = 4 + u0 = SVector{N, Float64}(ones(N) .+ randn(N) * 0.01) + + nlprob = NonlinearProblem(f_oop, u0, 2.0) + + @test !(solve(nlprob, NewtonRaphson()).alg.autodiff isa AutoPolyesterForwardDiff) +end