diff --git a/Project.toml b/Project.toml index 61066705..d164d8a7 100644 --- a/Project.toml +++ b/Project.toml @@ -45,13 +45,13 @@ Enzyme = "0.11" FiniteDiff = "2.8.1" ForwardDiff = "0.10" Graphs = "1" -LinearAlgebra = "1.6" +LinearAlgebra = "<0.0.1, 1" PackageExtensionCompat = "1" -Random = "1.6" +Random = "<0.0.1, 1" Reexport = "1" SciMLOperators = "0.3.7" Setfield = "1" -SparseArrays = "1.6" +SparseArrays = "<0.0.1, 1" StaticArrayInterface = "1.3" StaticArrays = "1" Symbolics = "5.5" @@ -62,7 +62,6 @@ Zygote = "0.6" julia = "1.6" [extras] -AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" @@ -76,4 +75,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["Test", "BandedMatrices", "BlockBandedMatrices", "Enzyme", "IterativeSolvers", "Pkg", "Random", "SafeTestsets", "Symbolics", "Zygote", "StaticArrays", "AllocCheck"] +test = ["Test", "BandedMatrices", "BlockBandedMatrices", "Enzyme", "IterativeSolvers", "Pkg", "Random", "SafeTestsets", "Symbolics", "Zygote", "StaticArrays"] diff --git a/test/allocs/Project.toml b/test/allocs/Project.toml new file mode 100644 index 00000000..2ce39fac --- /dev/null +++ b/test/allocs/Project.toml @@ -0,0 +1,2 @@ +[deps] +AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a" diff --git a/test/runtests.jl b/test/runtests.jl index 0708f4bc..52b53f92 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,8 +5,8 @@ const GROUP = get(ENV, "GROUP", "All") const is_APPVEYOR = (Sys.iswindows() && haskey(ENV, "APPVEYOR")) const is_TRAVIS = haskey(ENV, "TRAVIS") -function activate_gpu_env() - Pkg.activate("gpu") +function activate_env(env) + Pkg.activate(env) Pkg.develop(PackageSpec(path = dirname(@__DIR__))) Pkg.instantiate() end @@ -42,6 +42,7 @@ if GROUP == "Core" || GROUP == "All" end if GROUP == "InterfaceI" || GROUP == "All" + VERSION ≥ v"1.9" && activate_env("allocs") @time @safetestset "Jac Vecs and Hes Vecs" begin include("test_jaches_products.jl") end @@ -54,7 +55,7 @@ if GROUP == "InterfaceI" || GROUP == "All" end if GROUP == "GPU" - activate_gpu_env() + activate_env("gpu") @time @safetestset "GPU AD" begin include("test_gpu_ad.jl") end diff --git a/test/test_sparse_jacobian.jl b/test/test_sparse_jacobian.jl index 3049df17..1cccb01f 100644 --- a/test/test_sparse_jacobian.jl +++ b/test/test_sparse_jacobian.jl @@ -1,5 +1,5 @@ ## Sparse Jacobian tests -using AllocCheck, SparseDiffTools, +using SparseDiffTools, Symbolics, ForwardDiff, LinearAlgebra, SparseArrays, Zygote, Enzyme, Test, StaticArrays @views function fdiff(y, x) # in-place @@ -164,28 +164,32 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa end end -# Testing that the non-sparse jacobian's are non-allocating. -fvcat(x) = vcat(x, x) +@static if VERSION ≥ v"1.9" + using AllocCheck -x_sa = @SVector randn(Float32, 10); + # Testing that the non-sparse jacobian's are non-allocating. + fvcat(x) = vcat(x, x) -J_true_sa = ForwardDiff.jacobian(fvcat, x_sa) + x_sa = @SVector randn(Float32, 10); -@check_allocs function __sparse_jacobian_no_allocs(ad, sd, f::F, x) where {F} - return sparse_jacobian(ad, sd, f, x) -end + J_true_sa = ForwardDiff.jacobian(fvcat, x_sa) -@testset "Static Arrays" begin - @testset "No Allocations: $(difftype)" for difftype in (AutoSparseForwardDiff(), - AutoForwardDiff()) - J = __sparse_jacobian_no_allocs(difftype, NoSparsityDetection(), fvcat, x_sa) - @test J ≈ J_true_sa + @check_allocs function __sparse_jacobian_no_allocs(ad, sd, f::F, x) where {F} + return sparse_jacobian(ad, sd, f, x) end - @testset "Other Backends: $(difftype)" for difftype in (AutoSparseZygote(), - AutoZygote(), AutoSparseEnzyme(), AutoEnzyme(), AutoSparseFiniteDiff(), - AutoFiniteDiff()) - J = sparse_jacobian(difftype, NoSparsityDetection(), fvcat, x_sa) - @test J ≈ J_true_sa + @testset "Static Arrays" begin + @testset "No Allocations: $(difftype)" for difftype in (AutoSparseForwardDiff(), + AutoForwardDiff()) + J = __sparse_jacobian_no_allocs(difftype, NoSparsityDetection(), fvcat, x_sa) + @test J ≈ J_true_sa + end + + @testset "Other Backends: $(difftype)" for difftype in (AutoSparseZygote(), + AutoZygote(), AutoSparseEnzyme(), AutoEnzyme(), AutoSparseFiniteDiff(), + AutoFiniteDiff()) + J = sparse_jacobian(difftype, NoSparsityDetection(), fvcat, x_sa) + @test J ≈ J_true_sa + end end -end +end \ No newline at end of file