mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
Evaluation callback API
This adds a callback mechanism to for users to get notified just before jacobian and residual evaluations. This will enable aggressive caching and sharing of compute between cost functions. Change-Id: I67993726920218edf71ab9ae70c34c204756c71a
This commit is contained in:
@@ -85,6 +85,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ceres/evaluation_callback.h"
|
||||
#include "ceres/execution_summary.h"
|
||||
#include "ceres/internal/eigen.h"
|
||||
#include "ceres/internal/scoped_ptr.h"
|
||||
@@ -156,6 +157,14 @@ class ProgramEvaluator : public Evaluator {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Notify the user about a new evaluation point if they are interested.
|
||||
if (options_.evaluation_callback != NULL) {
|
||||
program_->CopyParameterBlockStateToUserState();
|
||||
options_.evaluation_callback->PrepareForEvaluation(
|
||||
/*jacobians=*/(gradient != NULL || jacobian != NULL),
|
||||
evaluate_options.new_evaluation_point);
|
||||
}
|
||||
|
||||
if (residuals != NULL) {
|
||||
VectorRef(residuals, program_->NumResiduals()).setZero();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user