Skip to content

Commit

Permalink
fix: minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 23, 2024
1 parent bf0473e commit a5e614c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
13 changes: 5 additions & 8 deletions lib/NonlinearSolveBase/src/autodiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const ForwardADs = (
function select_forward_mode_autodiff(
prob::AbstractNonlinearProblem, ad::AbstractADType; warn_check_mode::Bool = true)
if warn_check_mode && !(ADTypes.mode(ad) isa ADTypes.ForwardMode) &&
!(ADTypes.mode(ad) isa ADTypes.ForwardOrReverseMode)
!(ADTypes.mode(ad) isa ADTypes.ForwardOrReverseMode) &&
!is_finite_differences_backend(ad)
@warn "The chosen AD backend $(ad) is not a forward mode AD. Use with caution."
end
if incompatible_backend_and_problem(prob, ad)
Expand All @@ -60,13 +61,9 @@ end
function select_reverse_mode_autodiff(
prob::AbstractNonlinearProblem, ad::AbstractADType; warn_check_mode::Bool = true)
if warn_check_mode && !(ADTypes.mode(ad) isa ADTypes.ReverseMode) &&
!(ADTypes.mode(ad) isa ADTypes.ForwardOrReverseMode)
if !is_finite_differences_backend(ad)
@warn "The chosen AD backend $(ad) is not a reverse mode AD. Use with caution."
else
@warn "The chosen AD backend $(ad) is a finite differences backend. This might \
be slow and inaccurate. Use with caution."
end
!(ADTypes.mode(ad) isa ADTypes.ForwardOrReverseMode) &&
!is_finite_differences_backend(ad)
@warn "The chosen AD backend $(ad) is not a reverse mode AD. Use with caution."
end
if incompatible_backend_and_problem(prob, ad)
adₙ = select_reverse_mode_autodiff(prob, nothing; warn_check_mode)
Expand Down
1 change: 1 addition & 0 deletions lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module SimpleNonlinearSolve

using Accessors: @reset
using BracketingNonlinearSolve: BracketingNonlinearSolve
using CommonSolve: CommonSolve, solve, init, solve!
using ConcreteStructs: @concrete
using FastClosures: @closure
Expand Down
2 changes: 1 addition & 1 deletion src/core/generalized_first_order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function GeneralizedFirstOrderAlgorithm{concrete_jac, name}(;
max_shrink_times::Int = typemax(Int)) where {concrete_jac, name}
return GeneralizedFirstOrderAlgorithm{concrete_jac, name}(
linesearch, trustregion, descent, max_shrink_times,
autodiff, jvp_autodiff, vjp_autodiff)
autodiff, vjp_autodiff, jvp_autodiff)
end

concrete_jac(::GeneralizedFirstOrderAlgorithm{CJ}) where {CJ} = CJ
Expand Down

0 comments on commit a5e614c

Please sign in to comment.