Skip to content

Commit 766b5ef

Browse files
cstollmetameta-codesync[bot]
authored andcommitted
Split solver/momentum_ik.cpp into separate autograd files (#1082)
Summary: Pull Request resolved: #1082 This diff refactors `arvr/libraries/pymomentum/solver/momentum_ik.cpp` (originally 1505 LOC) by extracting the autograd function definitions into a separate `momentum_ik_autograd.cpp` / `.h` pair. **Changes:** - Created `momentum_ik_autograd.h` (265 LOC) containing: - `TensorMppcaModel` struct - `extractMppcaModel()` function declaration - `createIKProblem<T>()` template function declaration - `IKSolveFunction<T>`, `GradientFunction<T>`, `ResidualFunction<T>`, `SequenceIKSolveFunction<T>` class declarations - `IKProblemAutogradFunction<T, IKFunction>` struct declaration - Created `momentum_ik_autograd.cpp` (1002 LOC) containing implementations of all the above - Simplified `momentum_ik.cpp` (now 539 LOC) to contain only: - `applyIKProblemAutogradFunction` helper (in anonymous namespace) - Public pybind11 registration functions: `solveBodyIKProblem`, `computeGradient`, `computeResidual`, `computeJacobian`, `solveBodySequenceIKProblem`, `transformPose` This resolves the issue of a single file mixing autograd function definitions with pybind11 binding registration, making the code more maintainable and reducing `momentum_ik.cpp` well below the 1500 LOC target. Reviewed By: cdtwigg Differential Revision: D95089972 fbshipit-source-id: 578014cbcbca6908a1ffc44fa5edffd147dffc22
1 parent 3030ecf commit 766b5ef

File tree

4 files changed

+1271
-968
lines changed

4 files changed

+1271
-968
lines changed

pymomentum/cmake/build_variables.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,12 @@ diff_geometry_sources = [
179179

180180
solver_public_headers = [
181181
"solver/momentum_ik.h",
182+
"solver/momentum_ik_autograd.h",
182183
]
183184

184185
solver_sources = [
185186
"solver/momentum_ik.cpp",
187+
"solver/momentum_ik_autograd.cpp",
186188
"solver/solver_pybind.cpp",
187189
]
188190

0 commit comments

Comments
 (0)