Skip to content

Commit c8e6bd5

Browse files
authored
Separate tests by backend (#244)
* Separate tests by backend * Remove imports * Fix docs * Fix all
1 parent 16aa888 commit c8e6bd5

35 files changed

Lines changed: 394 additions & 322 deletions

DifferentiationInterface/docs/make.jl

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,16 @@ using Zygote: Zygote
2020

2121
cp(joinpath(@__DIR__, "..", "README.md"), joinpath(@__DIR__, "src", "index.md"); force=true)
2222

23-
extensions = [
24-
get_extension(DI, :DifferentiationInterfaceChainRulesCoreExt),
25-
get_extension(DI, :DifferentiationInterfaceDiffractorExt),
26-
get_extension(DI, :DifferentiationInterfaceEnzymeExt),
27-
get_extension(DI, :DifferentiationInterfaceFastDifferentiationExt),
28-
get_extension(DI, :DifferentiationInterfaceFiniteDiffExt),
29-
get_extension(DI, :DifferentiationInterfaceFiniteDifferencesExt),
30-
get_extension(DI, :DifferentiationInterfaceForwardDiffExt),
31-
get_extension(DI, :DifferentiationInterfacePolyesterForwardDiffExt),
32-
get_extension(DI, :DifferentiationInterfaceReverseDiffExt),
33-
get_extension(DI, :DifferentiationInterfaceSymbolicsExt),
34-
get_extension(DI, :DifferentiationInterfaceTapirExt),
35-
get_extension(DI, :DifferentiationInterfaceTrackerExt),
36-
get_extension(DI, :DifferentiationInterfaceZygoteExt),
37-
]
38-
3923
makedocs(;
40-
modules=[DifferentiationInterface, ADTypes, extensions...],
24+
modules=[DifferentiationInterface, ADTypes],
4125
authors="Guillaume Dalle, Adrian Hill",
4226
sitename="DifferentiationInterface.jl",
4327
format=Documenter.HTML(; assets=["assets/favicon.ico"]),
4428
pages=[
4529
"Home" => "index.md",
4630
"Start here" => ["tutorial.md", "overview.md", "backends.md"],
4731
"API reference" => "api.md",
48-
"Advanced" => ["design.md", "extensions.md", "overloads.md"],
32+
"Advanced" => ["design.md", "overloads.md"],
4933
],
5034
checkdocs=:exports,
5135
warnonly=[:missing_docs, :cross_references],

DifferentiationInterface/docs/src/extensions.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

DifferentiationInterface/src/second_order/second_order.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ end
3333
Return the _outer_ mode of the second-order backend.
3434
"""
3535
ADTypes.mode(backend::SecondOrder) = mode(outer(backend))
36+
37+
function twoarg_support(backend::SecondOrder)
38+
if Bool(twoarg_support(inner(backend))) && Bool(twoarg_support(outer(backend)))
39+
return TwoArgSupported()
40+
else
41+
return TwoArgNotSupported()
42+
end
43+
end

DifferentiationInterface/test/bonus/type_stability.jl

Lines changed: 0 additions & 13 deletions
This file was deleted.

DifferentiationInterface/test/bonus/weird_arrays.jl

Lines changed: 0 additions & 16 deletions
This file was deleted.

DifferentiationInterface/test/bonus/efficiency.jl renamed to DifferentiationInterface/test/efficiency/forwarddiff.jl.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
@testset verbose = false "ForwardDiff" begin
1+
using DataFrames: DataFrame
2+
using DifferentiationInterface, DifferentiationInterfaceTest
3+
import DifferentiationInterface as DI
4+
using ForwardDiff: ForwardDiff
5+
using Symbolics: Symbolics
6+
using Test
7+
8+
@testset verbose = false "Dense" begin
29
# derivative and gradient for `f(x)`
310

411
results1 = benchmark_differentiation(
@@ -39,9 +46,9 @@
3946
)
4047
@test row[:allocs] == 0
4148
end
42-
end
49+
end;
4350

44-
@testset verbose = false "Sparse ForwardDiff" begin
51+
@testset verbose = false "Sparse" begin
4552
# sparse jacobian for f!(x, y)
4653

4754
b_sparse = AutoSparse(
@@ -74,4 +81,4 @@ end
7481
@test row[:allocs] == 0
7582
@test row[:calls] < prod(row[:input_size])
7683
end
77-
end
84+
end;

DifferentiationInterface/test/first_order.jl

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using DifferentiationInterface, DifferentiationInterfaceTest
2+
using Diffractor: Diffractor
3+
4+
for backend in [AutoDiffractor()]
5+
@test check_available(backend)
6+
@test !check_twoarg(backend)
7+
@test !check_hessian(backend; verbose=false)
8+
end
9+
10+
test_differentiation(AutoDiffractor(); second_order=false, logging=LOGGING);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using DifferentiationInterface, DifferentiationInterfaceTest
2+
using Enzyme: Enzyme
3+
4+
backends = [
5+
AutoEnzyme(; mode=nothing),
6+
AutoEnzyme(; mode=Enzyme.Forward),
7+
AutoEnzyme(; mode=Enzyme.Reverse),
8+
AutoSparse(AutoEnzyme(; mode=nothing)),
9+
]
10+
11+
for backend in backends
12+
@test check_available(backend)
13+
@test check_twoarg(backend)
14+
@test !check_hessian(backend; verbose=false)
15+
end
16+
17+
test_differentiation(backends; second_order=false, logging=LOGGING);
18+
19+
test_differentiation(
20+
AutoEnzyme(; mode=Enzyme.Forward); # TODO: add more
21+
correctness=false,
22+
type_stability=true,
23+
second_order=false,
24+
logging=LOGGING,
25+
);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using DifferentiationInterface, DifferentiationInterfaceTest
2+
using FastDifferentiation: FastDifferentiation
3+
4+
backends = [AutoFastDifferentiation(), AutoSparse(AutoFastDifferentiation())]
5+
6+
for backend in backends
7+
@test check_available(backend)
8+
@test check_twoarg(backend)
9+
@test check_hessian(backend)
10+
end
11+
12+
test_differentiation(AutoFastDifferentiation(); logging=LOGGING);
13+
test_differentiation(
14+
AutoSparse(AutoFastDifferentiation());
15+
excluded=[JacobianScenario, HessianScenario],
16+
logging=LOGGING,
17+
);
18+
19+
test_differentiation(
20+
AutoSparse(AutoFastDifferentiation()),
21+
sparse_scenarios();
22+
sparsity=true,
23+
logging=LOGGING,
24+
);

0 commit comments

Comments
 (0)