-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathDifferentiationInterfaceFiniteDiffExt.jl
More file actions
39 lines (32 loc) · 1.08 KB
/
DifferentiationInterfaceFiniteDiffExt.jl
File metadata and controls
39 lines (32 loc) · 1.08 KB
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
29
30
31
32
33
34
35
36
37
38
39
module DifferentiationInterfaceFiniteDiffExt
using ADTypes: AutoFiniteDiff
import DifferentiationInterface as DI
using FiniteDiff:
DerivativeCache,
GradientCache,
HessianCache,
JacobianCache,
JVPCache,
finite_difference_derivative,
finite_difference_gradient,
finite_difference_gradient!,
finite_difference_hessian,
finite_difference_hessian!,
finite_difference_jacobian,
finite_difference_jacobian!,
finite_difference_jvp,
finite_difference_jvp!,
default_relstep
using LinearAlgebra: dot, mul!
DI.check_available(::AutoFiniteDiff) = true
DI.inner_preparation_behavior(::AutoFiniteDiff) = DI.PrepareInnerSimple()
# see https://github.com/SciML/ADTypes.jl/issues/33
fdtype(::AutoFiniteDiff{fdt}) where {fdt} = fdt
fdjtype(::AutoFiniteDiff{fdt,fdjt}) where {fdt,fdjt} = fdjt
fdhtype(::AutoFiniteDiff{fdt,fdjt,fdht}) where {fdt,fdjt,fdht} = fdht
# see https://docs.sciml.ai/FiniteDiff/stable/#f-Definitions
const FUNCTION_INPLACE = Val{true}
const FUNCTION_NOT_INPLACE = Val{false}
include("onearg.jl")
include("twoarg.jl")
end # module