forked from JuliaDiff/DifferentiationInterface.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.jl
More file actions
28 lines (20 loc) · 911 Bytes
/
check.jl
File metadata and controls
28 lines (20 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
check_available(backend)
Check whether `backend` is available (i.e. whether the extension is loaded) and return a `Bool`.
"""
check_available(backend::AbstractADType) = false
function check_available(backend::SecondOrder)
return check_available(inner(backend)) && check_available(outer(backend))
end
check_available(backend::AutoSparse) = check_available(dense_ad(backend))
function check_available(backend::MixedMode)
return check_available(forward_backend(backend)) &&
check_available(reverse_backend(backend))
end
check_available(::ADTypes.NoAutoDiff) = throw(ADTypes.NoAutoDiffSelectedError())
"""
check_inplace(backend)
Check whether `backend` supports differentiation of in-place functions and return a `Bool`.
"""
check_inplace(backend::AbstractADType) = Bool(inplace_support(backend))
check_inplace(::ADTypes.NoAutoDiff) = throw(ADTypes.NoAutoDiffSelectedError())