Skip to content

Commit 7e44a45

Browse files
committed
Support ADTypes.NoAutoDiff
1 parent a5fb081 commit 7e44a45

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

DifferentiationInterface/src/utils/check.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ function check_available(backend::MixedMode)
1616
check_available(reverse_backend(backend))
1717
end
1818

19+
@static if isdefined(ADTypes, :NoAutoDiff)
20+
check_available(::ADTypes.NoAutoDiff) = throw(ADTypes.NoAutoDiffSelectedError())
21+
end
22+
1923
"""
2024
check_inplace(backend)
2125
2226
Check whether `backend` supports differentiation of in-place functions and return a `Bool`.
2327
"""
2428
check_inplace(backend::AbstractADType) = Bool(inplace_support(backend))
29+
30+
@static if isdefined(ADTypes, :NoAutoDiff)
31+
check_inplace(::ADTypes.NoAutoDiff) = throw(ADTypes.NoAutoDiffSelectedError())
32+
end

DifferentiationInterface/test/Core/ZeroBackends/test.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ using Test
1010

1111
LOGGING = get(ENV, "CI", "false") == "false"
1212

13+
if isdefined(ADTypes, :NoAutoDiff)
14+
@test_throws NoAutoDiffSelectedError check_available(NoAutoDiff())
15+
@test_throws NoAutoDiffSelectedError check_inplace(NoAutoDiff())
16+
end
17+
1318
zero_backends = [AutoZeroForward(), AutoZeroReverse()]
1419

1520
for backend in zero_backends

0 commit comments

Comments
 (0)