Skip to content

Commit b3577f0

Browse files
committed
Remove DifferentiationInterface references
1 parent 9ccf137 commit b3577f0

11 files changed

Lines changed: 39 additions & 46 deletions

File tree

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[deps]
22
Bijectors = "76274a88-744f-5084-9051-94815aaf08c4"
33
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
4-
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
54
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
65
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
76
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"

docs/src/defining_examples.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,10 @@ function full_transform(x12)
207207
return StereographicProj()(x123)
208208
end
209209
210-
import DifferentiationInterface as DI
211210
using FiniteDifferences, LinearAlgebra
212211
x = [0.3, 0.4, sgn * sqrt(1 - 0.3^2 - 0.4^2)]
213212
214-
adtype = DI.AutoFiniteDifferences(; fdm=central_fdm(5, 1))
215-
jac = DI.jacobian(full_transform, adtype, x[1:2])
213+
jac = only(FiniteDifferences.jacobian(central_fdm(5, 1), full_transform, x[1:2]))
216214
logjac = logabsdet(jac)[1]
217215
```
218216

test/Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
77
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
88
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
99
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
10-
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
1110
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1211
DistributionsAD = "ced4e74d-a319-5a8a-b0ac-84af2272839c"
1312
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
@@ -39,7 +38,6 @@ ChainRules = "1"
3938
ChainRulesTestUtils = "0.7, 1"
4039
ChangesOfVariables = "0.1"
4140
Combinatorics = "1.0.2"
42-
DifferentiationInterface = "0.7.7"
4341
Distributions = "0.25"
4442
DistributionsAD = "0.6.3"
4543
Documenter = "1"

test/integration/enzyme/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[deps]
22
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
33
Bijectors = "76274a88-744f-5084-9051-94815aaf08c4"
4-
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
54
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
65
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
76
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

test/integration/enzyme/main.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
using ADTypes
22
using Bijectors
3-
using DifferentiationInterface
43
using Enzyme
54
using FiniteDifferences
65
using LinearAlgebra
76
using Test
87

9-
const REF_BACKEND = AutoFiniteDifferences(; fdm=central_fdm(5, 1))
8+
const REF_FDM = central_fdm(5, 1)
109

1110
function test_ad(f, backend, x; rtol=1e-6, atol=1e-6)
1211
@info "testing AD for function $f with $backend"
13-
ref_gradient = DifferentiationInterface.gradient(f, REF_BACKEND, x)
14-
gradient = DifferentiationInterface.gradient(f, backend, x)
12+
ref_gradient = only(FiniteDifferences.grad(REF_FDM, f, x))
13+
_, gradient = Bijectors._value_and_gradient(f, backend, x)
1514
@test isapprox(gradient, ref_gradient; rtol=rtol, atol=atol)
1615
end
1716

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Bijectors
22

3+
using ADTypes
34
using ChainRulesTestUtils
45
using Combinatorics
5-
using DifferentiationInterface
66
using DistributionsAD
77
using Documenter: Documenter
88
using FiniteDifferences
@@ -57,12 +57,12 @@ if TEST_ENZYME
5757
),
5858
]
5959
end
60-
const REF_BACKEND = AutoFiniteDifferences(; fdm=central_fdm(5, 1))
60+
const REF_FDM = central_fdm(5, 1)
6161

6262
function test_ad(f, backend, x; rtol=1e-6, atol=1e-6)
6363
@info "testing AD for function $f with $backend"
64-
ref_gradient = DifferentiationInterface.gradient(f, REF_BACKEND, x)
65-
gradient = DifferentiationInterface.gradient(f, backend, x)
64+
ref_gradient = only(FiniteDifferences.grad(REF_FDM, f, x))
65+
_, gradient = Bijectors._value_and_gradient(f, backend, x)
6666
@test isapprox(gradient, ref_gradient; rtol=rtol, atol=atol)
6767
end
6868

test/vector/cholesky.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module VBCholeskyTests
33
using Distributions
44
using LinearAlgebra
55
using Test
6+
using ADTypes: AutoEnzyme, AutoMooncake, AutoMooncakeForward, AutoReverseDiff
67
using Bijectors.VectorBijectors
7-
import DifferentiationInterface as DI
88
using ForwardDiff: ForwardDiff
99
using ReverseDiff: ReverseDiff
1010
using Mooncake: Mooncake
@@ -13,17 +13,17 @@ using Enzyme: Enzyme, set_runtime_activity, Const, Forward, Reverse
1313
# Need runtime activity for some reason.
1414
# TODO(penelopeysm): Report upstream
1515
const adtypes = [
16-
DI.AutoReverseDiff(),
17-
DI.AutoReverseDiff(; compile=true),
18-
DI.AutoMooncake(),
19-
DI.AutoMooncakeForward(),
20-
DI.AutoEnzyme(; mode=set_runtime_activity(Forward), function_annotation=Const),
21-
DI.AutoEnzyme(; mode=set_runtime_activity(Reverse), function_annotation=Const),
16+
AutoReverseDiff(),
17+
AutoReverseDiff(; compile=true),
18+
AutoMooncake(),
19+
AutoMooncakeForward(),
20+
AutoEnzyme(; mode=set_runtime_activity(Forward), function_annotation=Const),
21+
AutoEnzyme(; mode=set_runtime_activity(Reverse), function_annotation=Const),
2222
]
2323

2424
dists = [
25-
# Note: can't test LKJCholesky(1, ...) because its linked vector is length-zero and
26-
# DifferentiationInterface trips up with empty vectors.
25+
LKJCholesky(1, 1.0, 'U'),
26+
LKJCholesky(1, 1.0, 'L'),
2727
LKJCholesky(3, 1.0, 'U'),
2828
LKJCholesky(3, 1.0, 'L'),
2929
LKJCholesky(5, 1.0, 'U'),

test/vector/matrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Distributions
44
using LinearAlgebra
55
using Test
66
using PDMats
7-
import DifferentiationInterface as DI
7+
using ADTypes: AutoMooncake, AutoMooncakeForward
88
using Bijectors.VectorBijectors
99
using Enzyme: Enzyme
1010
using ForwardDiff: ForwardDiff
@@ -19,7 +19,7 @@ M = [1 2 3; 4 5 6]
1919
# TODO(penelopeysm): ReverseDiff gives wrong results when differentiating
2020
# through VecCorrBijector. Correctness tests are disabled for now.
2121
# https://github.com/TuringLang/Bijectors.jl/issues/434
22-
lkj_test_adtypes = [DI.AutoMooncake(), DI.AutoMooncakeForward()]
22+
lkj_test_adtypes = [AutoMooncake(), AutoMooncakeForward()]
2323

2424
# Don't check that from_linked_vec(d)(randn(...)) is in support for LKJ,
2525
# The reason is because the inverse bijector for LKJ causes the diagonal

test/vector/order.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module VBOrderTests
33
using Distributions
44
using LinearAlgebra
55
using Test
6+
using ADTypes: AutoEnzyme, AutoMooncake, AutoMooncakeForward
67
using Bijectors.VectorBijectors
78
using Bijectors: ordered
8-
import DifferentiationInterface as DI
99
using Enzyme: Enzyme
1010
using ForwardDiff: ForwardDiff
1111
using ReverseDiff: ReverseDiff
@@ -24,10 +24,10 @@ base_dists = [
2424
# because of the heavy setindex! usage.
2525
# https://github.com/JuliaDiff/ReverseDiff.jl/issues/43 We just avoid testing it for now.
2626
joint_test_adtypes = [
27-
DI.AutoMooncake(),
28-
DI.AutoMooncakeForward(),
29-
DI.AutoEnzyme(; mode=Enzyme.Forward),
30-
DI.AutoEnzyme(; mode=Enzyme.Reverse),
27+
AutoMooncake(),
28+
AutoMooncakeForward(),
29+
AutoEnzyme(; mode=Enzyme.Forward),
30+
AutoEnzyme(; mode=Enzyme.Reverse),
3131
]
3232

3333
@testset "Order statistics" begin

test/vector/product.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ using Distributions
44
using LinearAlgebra
55
using FillArrays: Fill
66
using Test
7+
using ADTypes: AutoEnzyme, AutoMooncake, AutoMooncakeForward, AutoReverseDiff
78
using Bijectors.VectorBijectors
8-
import DifferentiationInterface as DI
99
using ForwardDiff: ForwardDiff
1010
using ReverseDiff: ReverseDiff
1111
using Mooncake: Mooncake
1212
using Enzyme: Enzyme, set_runtime_activity, Const, Forward, Reverse
1313

1414
adtypes = [
15-
DI.AutoReverseDiff(),
16-
DI.AutoReverseDiff(; compile=true),
17-
DI.AutoMooncake(),
18-
DI.AutoMooncakeForward(),
15+
AutoReverseDiff(),
16+
AutoReverseDiff(; compile=true),
17+
AutoMooncake(),
18+
AutoMooncakeForward(),
1919
# Need runtime activity for some reason.
2020
# TODO(penelopeysm): Report upstream
21-
DI.AutoEnzyme(; mode=set_runtime_activity(Forward), function_annotation=Const),
22-
DI.AutoEnzyme(; mode=set_runtime_activity(Reverse), function_annotation=Const),
21+
AutoEnzyme(; mode=set_runtime_activity(Forward), function_annotation=Const),
22+
AutoEnzyme(; mode=set_runtime_activity(Reverse), function_annotation=Const),
2323
]
2424

2525
# Enzyme segfaults on 1.12 + Windows.
2626
# https://github.com/EnzymeAD/Enzyme.jl/issues/2986
2727
if VERSION >= v"1.12-" && Sys.iswindows()
28-
filter!(a -> !(a isa DI.AutoEnzyme), adtypes)
28+
filter!(a -> !(a isa AutoEnzyme), adtypes)
2929
end
3030

3131
# These are purposely chosen because the vec_length output is the same but
@@ -116,7 +116,7 @@ enzyme_failures = [
116116
)
117117
end
118118

119-
no_enzyme_adtypes = filter(adtype -> !(adtype isa DI.AutoEnzyme), adtypes)
119+
no_enzyme_adtypes = filter(adtype -> !(adtype isa AutoEnzyme), adtypes)
120120
for d in enzyme_failures
121121
VectorBijectors.test_all(
122122
d;

0 commit comments

Comments
 (0)