Draft
Conversation
…dentical factors into a single JacobianFactor
…TestProjectionFactor` wrapper.
…maps and automatically deduce factor constructor signatures using metaprogramming.
… several `BatchFactor` constructors.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new BatchFactor class that aggregates multiple identical factors into a single container, optimizing memory allocation through single malloc operations and creating large single-malloc Jacobian factors during linearization. This is designed to improve performance for Structure-from-Motion and SLAM applications with many similar factors.
Key Changes
- New
BatchFactortemplate class that wraps collections of factors - Map-based constructors for convenient factor batching
- Optimized linearization that produces a single JacobianFactor
- Test suite demonstrating usage with ProjectionFactor and BetweenFactor
- Timing example in timeSFMBAL.cpp comparing regular and batched approaches
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| gtsam/nonlinear/BatchFactor.h | New header file defining the BatchFactor template class with constructors, linearization, and helper methods |
| gtsam/nonlinear/tests/testBatchFactor.cpp | New test file with three test cases covering different constructor patterns and factor types |
| timing/timeSFMBAL.cpp | Modified to add BatchFactor usage example alongside existing conventional factor graph approach |
Member
Author
|
@ProfFan FYI |
Compare with Metis Dramatically simplified Hessian path (and way faster!) Add linearize time Hessian! Kill "fast" path revert that More micro-optimization ScratchMatrix offsets_ added a Value cache feat: Optimize BatchFactor linearization by enabling zero-malloc Jacobian computation via OptionalJacobian stride support. refactor: optimize BatchFactor key and dimension indexing. refactor: cache factor-specific key indices in BatchFactor for improved linearization and enable LM sequential Cholesky solver with summary verbosity. refactor: Pre-calculate key dimensions and indices in BatchFactor, add vector constructors, and enable LM parameters in timeSFMBAL. Address comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP: a new non-linear factor that collects many smaller factors but stores them with one malloc, and also creates a large single-malloc Jacobian factor.
Did some more work, including trying to linearize to hessian, and I ran on a larger problem. Verdict: whatever we gain in linearization dwarfs compared to slower elimination:

Raw Data