Skip to content

Commit

Permalink
[SymForce] CheckDerivatives gets any linearizer
Browse files Browse the repository at this point in the history
topic: fix_checkderivatives
relative: allow_dense_linearizer_in_optimizer
GitOrigin-RevId: f1134104eac3b00d07c16d949bbfb15c101ba94d
  • Loading branch information
bradley-solliday-skydio authored and aaron-skydio committed Jun 7, 2023
1 parent bdc665b commit d30d1b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions symforce/opt/dense_linearizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ template <typename Scalar>
class DenseLinearizer {
public:
using LinearizedDenseFactor = typename Factor<Scalar>::LinearizedDenseFactor;
using LinearizationType = DenseLinearization<Scalar>;

/**
* Construct a Linearizer from factors and optional keys
Expand Down
10 changes: 5 additions & 5 deletions symforce/opt/internal/derivative_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <spdlog/spdlog.h>

#include "../linearization.h"
#include "../linearizer.h"
#include "../util.h"
#include "../values.h"

Expand All @@ -28,12 +27,13 @@ namespace internal {
* Returns:
* true if `linearization` and numerical derivatives match
*/
template <typename Scalar>
bool CheckDerivatives(Linearizer<Scalar>& linearizer, const Values<Scalar>& values,
const index_t& index, const SparseLinearization<Scalar>& linearization,
template <typename Scalar, typename LinearizerType>
bool CheckDerivatives(LinearizerType& linearizer, const Values<Scalar>& values,
const index_t& index,
const typename LinearizerType::LinearizationType& linearization,
const Scalar epsilon, const bool verbose = true) {
// Make a copy of the linearization that we can relinearize into
SparseLinearization<Scalar> perturbed_linearization = linearization;
typename LinearizerType::LinearizationType perturbed_linearization = linearization;

bool success = true;

Expand Down
1 change: 1 addition & 0 deletions symforce/opt/linearizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Linearizer {
using Scalar = ScalarType;
using LinearizedDenseFactor = typename Factor<Scalar>::LinearizedDenseFactor;
using LinearizedSparseFactor = typename Factor<Scalar>::LinearizedSparseFactor;
using LinearizationType = SparseLinearization<Scalar>;

/**
* Construct a Linearizer from factors and optional keys
Expand Down

0 comments on commit d30d1b2

Please sign in to comment.