Skip to content

Commit dca86bc

Browse files
committed
Implement DifferentiationInterfaceTest infrastructure
1 parent ce18b29 commit dca86bc

8 files changed

Lines changed: 288 additions & 7 deletions

File tree

test/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[deps]
2+
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
23
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
34
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
45
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
56
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
7+
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
8+
DifferentiationInterfaceTest = "a82114a7-5aa3-49a8-9643-716bb13727a3"
69
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
710
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
811
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
@@ -22,8 +25,11 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2225
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2326

2427
[compat]
28+
ADTypes = "1"
2529
AxisArrays = "0.4.3"
2630
Compat = "3, 4"
31+
DifferentiationInterface = "0.7"
32+
DifferentiationInterfaceTest = "0.11"
2733
Distances = "0.10"
2834
Documenter = "0.25, 0.26, 0.27, 1"
2935
FiniteDifferences = "0.10.8, 0.11, 0.12"

test/basekernels/exponential.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# Standardised tests.
2323
TestUtils.test_interface(k)
2424
test_ADs(SEKernel)
25+
test_ADs_DIT(SEKernel)
2526
test_interface_ad_perf(_ -> SEKernel(), nothing, StableRNG(123456))
2627
end
2728
@testset "ExponentialKernel" begin
@@ -41,6 +42,7 @@
4142
# Standardised tests.
4243
TestUtils.test_interface(k)
4344
test_ADs(ExponentialKernel)
45+
test_ADs_DIT(ExponentialKernel)
4446
test_interface_ad_perf(_ -> ExponentialKernel(), nothing, StableRNG(123456))
4547
end
4648
@testset "GammaExponentialKernel" begin
@@ -59,6 +61,7 @@
5961
@test k2(v1, v2) k(v1, v2)
6062

6163
test_ADs-> GammaExponentialKernel(; gamma=only(γ)), [1 + 0.5 * rand()])
64+
test_ADs_DIT-> GammaExponentialKernel(; gamma=only(γ)), [1 + 0.5 * rand()])
6265
test_params(k, ([γ],))
6366
TestUtils.test_interface(GammaExponentialKernel(; γ=1.36))
6467

test/basekernels/fbm.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
test_interface(k; rtol=1e-5)
1515
@test repr(k) == "Fractional Brownian Motion Kernel (h = $(h))"
1616
test_ADs(FBMKernel; ADs=[:ReverseDiff])
17+
test_ADs_DIT(FBMKernel; ADs=[:ReverseDiff])
1718

1819
# Tests failing for ForwardDiff and Zygote@0.6.
1920
# Related to: https://github.com/FluxML/Zygote.jl/issues/1036

test/basekernels/matern.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Standardised tests.
2222
TestUtils.test_interface(k, Float64)
2323
test_ADs(() -> MaternKernel(; nu=ν))
24+
test_ADs_DIT(() -> MaternKernel(; nu=ν))
2425

2526
test_params(k, ([ν],))
2627

@@ -60,6 +61,7 @@
6061
# Standardised tests.
6162
TestUtils.test_interface(k, Float64)
6263
test_ADs(Matern32Kernel)
64+
test_ADs_DIT(Matern32Kernel)
6365
test_interface_ad_perf(_ -> Matern32Kernel(), nothing, StableRNG(123456))
6466
end
6567
@testset "Matern52Kernel" begin

test/kernels/scaledkernel.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# Standardised tests.
1313
TestUtils.test_interface(ks, Float64)
1414
test_ADs(x -> exp(x[1]) * SqExponentialKernel(), rand(1))
15+
test_ADs_DIT(x -> exp(x[1]) * SqExponentialKernel(), rand(1))
1516
test_interface_ad_perf(c -> c * SEKernel(), 0.3, StableRNG(123456))
1617

1718
test_params(s * k, (k, [s]))

test/mokernels/intrinsiccoregion.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
)
4242

4343
test_ADs(icoregionkernel; dims=dims)
44+
test_ADs_DIT(icoregionkernel; dims=dims)
4445

4546
@test string(icoregionkernel) ==
4647
string("Intrinsic Coregion Kernel: ", kernel, " with ", dims.out, " outputs")

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ using ForwardDiff: ForwardDiff
2020
using ReverseDiff: ReverseDiff
2121
using FiniteDifferences: FiniteDifferences
2222
using Compat: only
23+
using ADTypes: AutoForwardDiff, AutoReverseDiff, AutoZygote, AutoFiniteDifferences
24+
using DifferentiationInterface: DifferentiationInterface as DI
25+
using DifferentiationInterfaceTest: Scenario, test_differentiation
2326

2427
using KernelFunctions: SimpleKernel, metric, kappa, ColVecs, RowVecs, TestUtils
2528

0 commit comments

Comments
 (0)