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:
Keir Mierle
2018-01-10 17:14:57 -08:00
parent 83098e12e8
commit 7bdceb46cf
15 changed files with 643 additions and 38 deletions
+9
View File
@@ -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();
}