Skip to content

Remove special cases for AbstractFiniteDifference #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AbstractDifferentiationZygoteExt = "Zygote"
ChainRulesCore = "1"
DiffResults = "1"
ExprTools = "0.1"
FiniteDifferences = "0.12"
FiniteDifferences = "0.12.28"
ForwardDiff = "0.10"
Requires = "1"
ReverseDiff = "1"
Expand Down
18 changes: 0 additions & 18 deletions src/AbstractDifferentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ second_lowest(b::AbstractBackend) = b
second_lowest(b::HigherOrderBackend) = lowest(reduce_order(b))

# If the primal value is in y, extract it.
# Otherwise, re-compute it, e.g. in finite diff.
primal_value(::AbstractFiniteDifference, ::Any, f, xs) = f(xs...)
primal_value(::AbstractBackend, ys, ::Any, ::Any) = primal_value(ys)
primal_value(x::Tuple) = map(primal_value, x)
primal_value(x) = x
Expand Down Expand Up @@ -68,10 +66,6 @@ end
function value_and_jacobian(ab::AbstractBackend, f, xs...)
local value
primalcalled = false
if lowest(ab) isa AbstractFiniteDifference
value = primal_value(ab, nothing, f, xs)
primalcalled = true
end
jacs = jacobian(lowest(ab), (_xs...,) -> begin
v = f(_xs...)
if !primalcalled
Expand All @@ -91,10 +85,6 @@ function value_and_hessian(ab::AbstractBackend, f, x)

local value
primalcalled = false
if ab isa AbstractFiniteDifference
value = primal_value(ab, nothing, f, (x,))
primalcalled = true
end
hess = jacobian(second_lowest(ab), _x -> begin
v, g = value_and_gradient(lowest(ab), f, _x)
if !primalcalled
Expand Down Expand Up @@ -187,10 +177,6 @@ function value_and_pushforward_function(
@assert length(ds) == length(xs)
local value
primalcalled = false
if ab isa AbstractFiniteDifference
value = primal_value(ab, nothing, f, xs)
primalcalled = true
end
pf = pushforward_function(lowest(ab), (_xs...,) -> begin
vs = f(_xs...)
if !primalcalled
Expand Down Expand Up @@ -241,10 +227,6 @@ function value_and_pullback_function(
return (ws) -> begin
local value
primalcalled = false
if ab isa AbstractFiniteDifference
value = primal_value(ab, nothing, f, xs)
primalcalled = true
end
if ws === nothing
vs = f(xs...)
if !primalcalled
Expand Down