Skip to content

Commit 6ed3ea9

Browse files
cdtwiggmeta-codesync[bot]
authored andcommitted
Remove torch dependency from geometry module (#964)
Summary: Pull Request resolved: #964 Removes all torch/aten dependencies from the pymomentum.geometry module now that all geometry operations have been migrated to numpy arrays. This includes: - Removing torch header includes from C++ source files - Removing torch import from the Python module initialization - Removing torch from BUCK python_typing_deps - Removing PYMOMENTUM_LIMITED_TORCH_API guards (no longer needed) - Regenerating geometry.pyi to reflect numpy-based API (to_arrays instead of to_tensors) The geometry module now operates entirely on numpy arrays via the Buffer protocol. The diff_geometry module retains its torch dependency for differentiable operations. Reviewed By: jeongseok-meta Differential Revision: D89893026
1 parent 89c50e5 commit 6ed3ea9

File tree

7 files changed

+6
-24
lines changed

7 files changed

+6
-24
lines changed

pymomentum/geometry/character_pybind.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
#include "pymomentum/geometry/momentum_geometry.h"
1313
#include "pymomentum/geometry/momentum_io.h"
1414

15-
// Keep tensor skinning for functions that don't have array equivalents yet
16-
#include "pymomentum/tensor_momentum/tensor_skinning.h"
17-
#include "pymomentum/torch_bridge.h"
18-
1915
#include <momentum/character/blend_shape.h>
2016
#include <momentum/character/character.h>
2117
#include <momentum/character/character_utility.h>

pymomentum/geometry/geometry_pybind.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,6 @@ PYBIND11_MODULE(geometry, m) {
7474
m.doc() = "Geometry and forward kinematics for momentum models. ";
7575
m.attr("__name__") = "pymomentum.geometry";
7676

77-
#ifdef PYMOMENTUM_LIMITED_TORCH_API
78-
m.attr("AUTOGRAD_ENABLED") = false;
79-
#else
80-
m.attr("AUTOGRAD_ENABLED") = true;
81-
#endif
82-
83-
pybind11::module_::import("torch"); // @dep=//caffe2:torch
84-
8577
m.attr("PARAMETERS_PER_JOINT") = mm::kParametersPerJoint;
8678

8779
py::enum_<mm::FbxUpVector>(m, "FbxUpVector")

pymomentum/geometry/momentum_geometry.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,12 @@
3838

3939
#include <dispenso/parallel_for.h>
4040

41-
#ifndef PYMOMENTUM_LIMITED_TORCH_API
42-
#include <torch/csrc/jit/python/python_ivalue.h>
43-
#endif
4441
#include <Eigen/Core>
4542

4643
#include <cstdint>
4744

4845
namespace py = pybind11;
4946

50-
#ifndef PYMOMENTUM_LIMITED_TORCH_API
51-
using torch::autograd::AutogradContext;
52-
using torch::autograd::variable_list;
53-
#endif
54-
5547
namespace pymomentum {
5648

5749
template <typename T>

pymomentum/test/test_blend_shape.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
import unittest
99

1010
import numpy as np
11+
import pymomentum.diff_geometry as pym_diff_geometry
1112
import pymomentum.geometry as pym_geometry
1213
import pymomentum.skel_state as pym_skel_state
1314
import pymomentum.solver as pym_solver
1415
import torch
1516
from pymomentum.solver import ErrorFunctionType
1617

1718
# Flag to check if autograd is enabled (disabled in arvr build modes)
18-
AUTOGRAD_ENABLED: bool = pym_geometry.AUTOGRAD_ENABLED
19+
AUTOGRAD_ENABLED: bool = pym_diff_geometry.AUTOGRAD_ENABLED
1920

2021

2122
def _build_shape_vectors(

pymomentum/test/test_pose_prior.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
logger: logging.Logger = logging.getLogger(__name__)
1717

1818
# Flag to check if autograd is enabled (disabled in arvr build modes)
19-
AUTOGRAD_ENABLED: bool = pym_geometry.AUTOGRAD_ENABLED
19+
AUTOGRAD_ENABLED: bool = pym_diff_geometry.AUTOGRAD_ENABLED
2020

2121

2222
class TestPosePrior(unittest.TestCase):

pymomentum/test/test_sequence_ik.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import torch
1414
from pymomentum.solver import ErrorFunctionType
1515

16-
AUTOGRAD_ENABLED: bool = pym_geometry.AUTOGRAD_ENABLED
16+
AUTOGRAD_ENABLED: bool = pym_diff_geometry.AUTOGRAD_ENABLED
1717

1818

1919
class TestSolver(unittest.TestCase):

pymomentum/test/test_skel_state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
from typing import Tuple
1010

1111
import numpy as np
12+
import pymomentum.diff_geometry as pym_diff_geometry
1213
import pymomentum.geometry as pym_geometry
1314
import pymomentum.quaternion as pym_quaternion
1415
import pymomentum.skel_state as pym_skel_state
1516
import torch
1617
from torch.nn import Parameter as P
1718

1819
# Flag to check if autograd is enabled (disabled in arvr build modes)
19-
AUTOGRAD_ENABLED: bool = pym_geometry.AUTOGRAD_ENABLED
20+
AUTOGRAD_ENABLED: bool = pym_diff_geometry.AUTOGRAD_ENABLED
2021

2122

2223
def generate_skel_state_components(

0 commit comments

Comments
 (0)