Skip to content
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

update for ManifoldDiff v0.4 backend #1851

Merged
merged 1 commit into from
Dec 1, 2024
Merged
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ Interpolations = "0.15"
JSON3 = "1"
KernelDensityEstimate = "0.5.6"
LinearAlgebra = "1.10"
ManifoldDiff = "0.3"
ManifoldDiff = "0.3, 0.4"
Manifolds = "0.10"
ManifoldsBase = "0.15"
Manopt = "0.4.40, 0.5"
Manopt = "^0.5.3"
MetaGraphs = "0.7, 0.8"
Optim = "1"
OrderedCollections = "1"
Expand Down
6 changes: 5 additions & 1 deletion src/parametric/services/ParametricOptim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ function optimizeManifold_FD(
)
# finitediff setup
r_backend = ManifoldDiff.TangentDiffBackend(
ManifoldDiff.FiniteDifferencesBackend()
if v"0.4" <= pkgversion(ManifoldDiff)
ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1))
else
ManifoldDiff.FiniteDifferencesBackend()
end
)

## finitediff gradient (non-manual)
Expand Down
8 changes: 7 additions & 1 deletion src/services/FactorGradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ function factorJacobian(
fg,
faclabel::Symbol,
p0 = ArrayPartition(first.(getVal.(fg, getVariableOrder(fg, faclabel), solveKey = :parametric))...),
backend = ManifoldDiff.TangentDiffBackend(ManifoldDiff.FiniteDiffBackend()),
backend = ManifoldDiff.TangentDiffBackend(
if v"0.4" <= pkgversion(ManifoldDiff)
ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1))
else
ManifoldDiff.FiniteDifferencesBackend()
end
)
)

fac = getFactor(fg, faclabel)
Expand Down
16 changes: 13 additions & 3 deletions test/manifolds/factordiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,15 @@ function resid_SE2(X, p, q)
end


# finitediff setup
# finitediff setup
r_backend = ManifoldDiff.TangentDiffBackend(
ManifoldDiff.FiniteDifferencesBackend()
if v"0.4" <= pkgversion(ManifoldDiff)
ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1))
else
ManifoldDiff.FiniteDifferencesBackend()
end
)

Me = Euclidean(3)

function _factorJac!(J, z, p1, p2)
Expand All @@ -123,9 +127,15 @@ J_ = _factorJac!(J, z, p1, p2)
# @profview _factorJac!(J, z, p1, p2)

if false
# finitediff setup
z_backend = ManifoldDiff.TangentDiffBackend(
ManifoldDiff.ZygoteDiffBackend()
if v"0.4" <= pkgversion(ManifoldDiff)
ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1))
else
ManifoldDiff.FiniteDifferencesBackend()
end
)

g = ManifoldDiff.jacobian(M, Euclidean(3), f_SE2_x0, p1, z_backend)
else
@info "ManifoldDiff.ZygoteDiffBackend usage still under development (23Q3)"
Expand Down
4 changes: 4 additions & 0 deletions test/manifolds/manifolddiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import Rotations as _Rot

# finitediff setup
r_backend = ManifoldDiff.TangentDiffBackend(
if v"0.4" <= pkgversion(ManifoldDiff)
ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1))
else
ManifoldDiff.FiniteDifferencesBackend()
end
)

##
Expand Down
Loading