Skip to content

Commit 2b67d66

Browse files
committed
Conditionally add AllocCheck in 1.9
1 parent 69aaa0b commit 2b67d66

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

Project.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ Enzyme = "0.11"
4545
FiniteDiff = "2.8.1"
4646
ForwardDiff = "0.10"
4747
Graphs = "1"
48-
LinearAlgebra = "1.6"
48+
LinearAlgebra = "<0.0.1, 1"
4949
PackageExtensionCompat = "1"
50-
Random = "1.6"
50+
Random = "<0.0.1, 1"
5151
Reexport = "1"
5252
SciMLOperators = "0.3.7"
5353
Setfield = "1"
54-
SparseArrays = "1.6"
54+
SparseArrays = "<0.0.1, 1"
5555
StaticArrayInterface = "1.3"
5656
StaticArrays = "1"
5757
Symbolics = "5.5"
@@ -62,7 +62,6 @@ Zygote = "0.6"
6262
julia = "1.6"
6363

6464
[extras]
65-
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
6665
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
6766
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
6867
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
@@ -76,4 +75,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7675
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
7776

7877
[targets]
79-
test = ["Test", "BandedMatrices", "BlockBandedMatrices", "Enzyme", "IterativeSolvers", "Pkg", "Random", "SafeTestsets", "Symbolics", "Zygote", "StaticArrays", "AllocCheck"]
78+
test = ["Test", "BandedMatrices", "BlockBandedMatrices", "Enzyme", "IterativeSolvers", "Pkg", "Random", "SafeTestsets", "Symbolics", "Zygote", "StaticArrays"]

test/allocs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"

test/runtests.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const GROUP = get(ENV, "GROUP", "All")
55
const is_APPVEYOR = (Sys.iswindows() && haskey(ENV, "APPVEYOR"))
66
const is_TRAVIS = haskey(ENV, "TRAVIS")
77

8-
function activate_gpu_env()
9-
Pkg.activate("gpu")
8+
function activate_env(env)
9+
Pkg.activate(env)
1010
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
1111
Pkg.instantiate()
1212
end
@@ -42,6 +42,7 @@ if GROUP == "Core" || GROUP == "All"
4242
end
4343

4444
if GROUP == "InterfaceI" || GROUP == "All"
45+
VERSION v"1.9" && activate_env("allocs")
4546
@time @safetestset "Jac Vecs and Hes Vecs" begin
4647
include("test_jaches_products.jl")
4748
end
@@ -54,7 +55,7 @@ if GROUP == "InterfaceI" || GROUP == "All"
5455
end
5556

5657
if GROUP == "GPU"
57-
activate_gpu_env()
58+
activate_env("gpu")
5859
@time @safetestset "GPU AD" begin
5960
include("test_gpu_ad.jl")
6061
end

test/test_sparse_jacobian.jl

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Sparse Jacobian tests
2-
using AllocCheck, SparseDiffTools,
2+
using SparseDiffTools,
33
Symbolics, ForwardDiff, LinearAlgebra, SparseArrays, Zygote, Enzyme, Test, StaticArrays
44

55
@views function fdiff(y, x) # in-place
@@ -164,28 +164,32 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
164164
end
165165
end
166166

167-
# Testing that the non-sparse jacobian's are non-allocating.
168-
fvcat(x) = vcat(x, x)
167+
@static if VERSION v"1.9"
168+
using AllocCheck
169169

170-
x_sa = @SVector randn(Float32, 10);
170+
# Testing that the non-sparse jacobian's are non-allocating.
171+
fvcat(x) = vcat(x, x)
171172

172-
J_true_sa = ForwardDiff.jacobian(fvcat, x_sa)
173+
x_sa = @SVector randn(Float32, 10);
173174

174-
@check_allocs function __sparse_jacobian_no_allocs(ad, sd, f::F, x) where {F}
175-
return sparse_jacobian(ad, sd, f, x)
176-
end
175+
J_true_sa = ForwardDiff.jacobian(fvcat, x_sa)
177176

178-
@testset "Static Arrays" begin
179-
@testset "No Allocations: $(difftype)" for difftype in (AutoSparseForwardDiff(),
180-
AutoForwardDiff())
181-
J = __sparse_jacobian_no_allocs(difftype, NoSparsityDetection(), fvcat, x_sa)
182-
@test J J_true_sa
177+
@check_allocs function __sparse_jacobian_no_allocs(ad, sd, f::F, x) where {F}
178+
return sparse_jacobian(ad, sd, f, x)
183179
end
184180

185-
@testset "Other Backends: $(difftype)" for difftype in (AutoSparseZygote(),
186-
AutoZygote(), AutoSparseEnzyme(), AutoEnzyme(), AutoSparseFiniteDiff(),
187-
AutoFiniteDiff())
188-
J = sparse_jacobian(difftype, NoSparsityDetection(), fvcat, x_sa)
189-
@test J J_true_sa
181+
@testset "Static Arrays" begin
182+
@testset "No Allocations: $(difftype)" for difftype in (AutoSparseForwardDiff(),
183+
AutoForwardDiff())
184+
J = __sparse_jacobian_no_allocs(difftype, NoSparsityDetection(), fvcat, x_sa)
185+
@test J J_true_sa
186+
end
187+
188+
@testset "Other Backends: $(difftype)" for difftype in (AutoSparseZygote(),
189+
AutoZygote(), AutoSparseEnzyme(), AutoEnzyme(), AutoSparseFiniteDiff(),
190+
AutoFiniteDiff())
191+
J = sparse_jacobian(difftype, NoSparsityDetection(), fvcat, x_sa)
192+
@test J J_true_sa
193+
end
190194
end
191-
end
195+
end

0 commit comments

Comments
 (0)