diff --git a/Project.toml b/Project.toml index b1848a75..ec89a8b7 100644 --- a/Project.toml +++ b/Project.toml @@ -24,7 +24,6 @@ Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -Tricks = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" VertexSafeGraphs = "19fa3120-7c27-5ec5-8db8-b0b0aa330d6f" @@ -64,7 +63,6 @@ SparseArrays = "<0.0.1, 1" StaticArrayInterface = "1.3" StaticArrays = "1" Symbolics = "5.5, 6" -Tricks = "0.1.6" UnPack = "1" VertexSafeGraphs = "0.2" Zygote = "0.6" diff --git a/ext/SparseDiffToolsZygoteExt.jl b/ext/SparseDiffToolsZygoteExt.jl index 9f7d491a..4d5a3efd 100644 --- a/ext/SparseDiffToolsZygoteExt.jl +++ b/ext/SparseDiffToolsZygoteExt.jl @@ -5,7 +5,6 @@ import SparseDiffTools: SparseDiffTools, DeivVecTag, AutoDiffVJP, __test_backend import ForwardDiff: ForwardDiff, Dual, partials import SciMLOperators: update_coefficients, update_coefficients! import Setfield: @set! -import Tricks: static_hasmethod import SparseDiffTools: numback_hesvec!, numback_hesvec, autoback_hesvec!, autoback_hesvec, auto_vecjac!, @@ -101,7 +100,7 @@ end # VJP methods function auto_vecjac!(du, f::F, x, v) where {F} - !static_hasmethod(f, typeof((x,))) && + !hasmethod(f, typeof((x,))) && error("For inplace function use autodiff = AutoFiniteDiff()") du .= reshape(SparseDiffTools.auto_vecjac(f, x, v), size(du)) end @@ -113,7 +112,7 @@ end # overload operator interface function SparseDiffTools._vecjac(f::F, _, u, autodiff::AutoZygote) where {F} - !static_hasmethod(f, typeof((u,))) && + !hasmethod(f, typeof((u,))) && error("For inplace function use autodiff = AutoFiniteDiff()") pullback = Zygote.pullback(f, u) return AutoDiffVJP(f, u, (), autodiff, pullback) diff --git a/src/SparseDiffTools.jl b/src/SparseDiffTools.jl index c7d3d979..b985abd1 100644 --- a/src/SparseDiffTools.jl +++ b/src/SparseDiffTools.jl @@ -22,7 +22,6 @@ using SciMLOperators, LinearAlgebra, Random import DataStructures: DisjointSets, find_root!, union! import SciMLOperators: update_coefficients, update_coefficients! import Setfield: @set! -import Tricks: Tricks, static_hasmethod import PackageExtensionCompat: @require_extensions function __init__() diff --git a/src/differentiation/common.jl b/src/differentiation/common.jl index 83fb438b..e1c04b3f 100644 --- a/src/differentiation/common.jl +++ b/src/differentiation/common.jl @@ -49,8 +49,8 @@ function JacFunctionWrapper(f::F, fu_, u, p, t; if deporder # Check this first else we were breaking things # In the next breaking release, we will fix the ordering of the checks - iip = static_hasmethod(f, typeof((fu, u))) - oop = static_hasmethod(f, typeof((u,))) + iip = hasmethod(f, typeof((fu, u))) + oop = hasmethod(f, typeof((u,))) if iip || oop if p !== nothing || t !== nothing Base.depwarn( @@ -74,8 +74,8 @@ function JacFunctionWrapper(f::F, fu_, u, p, t; end if t !== nothing - iip = static_hasmethod(f, typeof((fu, u, p, t))) - oop = static_hasmethod(f, typeof((u, p, t))) + iip = hasmethod(f, typeof((fu, u, p, t))) + oop = hasmethod(f, typeof((u, p, t))) if !iip && !oop throw(ArgumentError("""`p` and `t` provided but `f(u, p, t)` or `f(fu, u, p, t)` not defined for `f`!""")) @@ -83,8 +83,8 @@ function JacFunctionWrapper(f::F, fu_, u, p, t; return JacFunctionWrapper{iip, oop, 1, F, typeof(fu), typeof(p), typeof(t)}(f, fu, p, t) elseif p !== nothing - iip = static_hasmethod(f, typeof((fu, u, p))) - oop = static_hasmethod(f, typeof((u, p))) + iip = hasmethod(f, typeof((fu, u, p))) + oop = hasmethod(f, typeof((u, p))) if !iip && !oop throw(ArgumentError("""`p` is provided but `f(u, p)` or `f(fu, u, p)` not defined for `f`!""")) @@ -94,8 +94,8 @@ function JacFunctionWrapper(f::F, fu_, u, p, t; end if !deporder - iip = static_hasmethod(f, typeof((fu, u))) - oop = static_hasmethod(f, typeof((u,))) + iip = hasmethod(f, typeof((fu, u))) + oop = hasmethod(f, typeof((u,))) if !iip && !oop throw(ArgumentError("""`p` is provided but `f(u)` or `f(fu, u)` not defined for `f`!""")) diff --git a/src/differentiation/jaches_products.jl b/src/differentiation/jaches_products.jl index fcc85a87..04c00917 100644 --- a/src/differentiation/jaches_products.jl +++ b/src/differentiation/jaches_products.jl @@ -212,7 +212,7 @@ function (L::FwdModeAutoDiffVecProd)(dv, v, p, t) end function Base.resize!(L::FwdModeAutoDiffVecProd, n::Integer) - static_hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n) + hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n) resize!(L.u, n) for v in L.cache @@ -304,7 +304,7 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing; (cache1, cache2, cache3), numauto_hesvec, numauto_hesvec! elseif autodiff isa AutoZygote - @assert static_hasmethod(autoback_hesvec, typeof((f, u, u))) "To use AutoZygote() AD, first load Zygote with `using Zygote`, or `import Zygote`" + @assert hasmethod(autoback_hesvec, typeof((f, u, u))) "To use AutoZygote() AD, first load Zygote with `using Zygote`, or `import Zygote`" cache1 = Dual{ typeof(ForwardDiff.Tag(tag, eltype(u))), eltype(u), 1 @@ -316,8 +316,8 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing; error("Set autodiff to either AutoForwardDiff(), AutoZygote(), or AutoFiniteDiff()") end - outofplace = static_hasmethod(f, typeof((u,))) - isinplace = static_hasmethod(f, typeof((u,))) + outofplace = hasmethod(f, typeof((u,))) + isinplace = hasmethod(f, typeof((u,))) if !(isinplace) & !(outofplace) error("$f must have signature f(u).") @@ -347,8 +347,8 @@ function HesVecGrad(f, u::AbstractArray, p = nothing, t = nothing; error("Set autodiff to either AutoForwardDiff(), or AutoFiniteDiff()") end - outofplace = static_hasmethod(f, typeof((u,))) - isinplace = static_hasmethod(f, typeof((u, u))) + outofplace = hasmethod(f, typeof((u,))) + isinplace = hasmethod(f, typeof((u, u))) if !(isinplace) & !(outofplace) error("$f must have signature f(u), or f(du, u).") diff --git a/src/differentiation/vecjac_products.jl b/src/differentiation/vecjac_products.jl index 4113e655..8ab0039b 100644 --- a/src/differentiation/vecjac_products.jl +++ b/src/differentiation/vecjac_products.jl @@ -152,7 +152,7 @@ function (L::AutoDiffVJP{<:AutoFiniteDiff})(dv, v, p, t; VJP_input = nothing) end function Base.resize!(L::AutoDiffVJP, n::Integer) - static_hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n) + hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n) resize!(L.u, n) for v in L.cache resize!(v, n)