Factor Graph DSL Interface - Building

permalink

Idea: Factor Graph DSL interface

General idea: define an alternate [modern?] C++ interface to the GTSAM math

Aside: the example code sets up shared pointers, which seems like it could lead to lots of runtime memory allocation when setting up and evolving the graph. Could this potentially be an area to minimize, e.g. by setting up an arena of maximum size and pre-allocate or setting up equivalent math but with a fixed ahead-of-time statically allocated memory structure?

  • Goal: statically allocate the graph and compress memory footprint into a contiguous block, hoping to show improved performance by reduced memory access and removing memory allocation/deallocation from the loop
  • Hypothesis: I can make a new frontend but still call the underlying math
  • Hypothesis: This static allocation / known structure could unlock some interesting common-subexpression-elimination opportunities to increase the speed of the graph
  • Hypothesis: If you're laying out memory structurally, could you make it cache-line-aware or cache-oblivious in how you lay out terms so you maximize parallel processing and hot L1, etc. data reuse?

Aside: it seems like a DSL that constexpr compiles itself could be helpful to pull errors to compile time? e.g. what if you use different shapes for assumptions about the integers in the graph, like saying you assume one state is Pose2d for its prior but then the binary factor to the next state assumes it’s Pose3d?

Hypothesis for an alternate wrapper: When assembling the graph at compile time or constraining the graph at compile time, try to avoid an arbitrary stack of templates, e.g. Factor<A, Factor<B, Factor<C, …>>> if you can instead do something like array<Factor>{A, B, C, ...} ?

Related Posts: