From 23b4e74768fae4e358920f00fcd5f01a5ac03f01 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Tue, 31 Oct 2023 11:34:47 -0400 Subject: [PATCH] Proper dispatch --- src/linesearch.jl | 8 ++++---- src/utils.jl | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/linesearch.jl b/src/linesearch.jl index 272d8b7cf..760f67769 100644 --- a/src/linesearch.jl +++ b/src/linesearch.jl @@ -26,22 +26,22 @@ function LineSearch(; method = nothing, autodiff = AutoFiniteDiff(), alpha = tru return LineSearch(method, autodiff, alpha) end -@inline function init_linesearch_cache(ls::LineSearch, args...) - return init_linesearch_cache(ls.method, ls, args...) +@inline function init_linesearch_cache(ls::LineSearch, f::F, u, p, fu, iip) where {F} + return init_linesearch_cache(ls.method, ls, f, u, p, fu, iip) end @concrete struct NoLineSearchCache α end -function init_linesearch_cache(::Nothing, ls, f::F, u, p, fu, iip) where {F} +function init_linesearch_cache(::Nothing, ls::LineSearch, f::F, u, p, fu, iip) where {F} return NoLineSearchCache(convert(eltype(u), ls.α)) end perform_linesearch!(cache::NoLineSearchCache, u, du) = cache.α # LineSearches.jl doesn't have a supertype so default to that -function init_linesearch_cache(_, ls, f::F, u, p, fu, iip) where {F} +function init_linesearch_cache(_, ls::LineSearch, f::F, u, p, fu, iip) where {F} return LineSearchesJLCache(ls, f, u, p, fu, iip) end diff --git a/src/utils.jl b/src/utils.jl index ba1230258..949583095 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -48,8 +48,8 @@ function default_adargs_to_adtype(; chunk_size = missing, autodiff = nothing, ad = _unwrap_val(autodiff) # We don't really know the typeof the input yet, so we can't use the correct tag! - ad && return AutoForwardDiff{_unwrap_val(chunk_size), NonlinearSolveTag}(; - tag = NonlinearSolveTag()) + ad && return AutoForwardDiff{_unwrap_val(chunk_size), NonlinearSolveTag}( + NonlinearSolveTag()) return AutoFiniteDiff(; fdtype = diff_type) end