geometry
Use GradSLAM's tensor geometry utilities for camera projection, homogeneous coordinates, pixel grids, rigid transforms, quaternions, SE(3) exponential maps, and point or normal frame changes.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- geometry
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use GradSLAM's tensor geometry utilities for camera projection, homogeneous coordinates, pixel grids, rigid transforms, quaternions, SE(3) exponential maps, and point or normal frame changes.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md8.7 KB
- 参考文档references/troubleshooting.md6.6 KB
- 参考文档references/workflows.md7.6 KB
- 脚本scripts/geometry_smoke.py4.3 KB
03 SKILL.md 正文
Geometry
Use this skill when a GradSLAM operation needs camera-coordinate projection, depth unprojection, intrinsics handling, pixel-grid conversion, rigid-body transforms, quaternion rotation, or Lie-group SE(3) updates. The functions are PyTorch tensor operations: preserve the input dtype/device and keep tensors in the expected trailing-dimension layout.
Read the focused contracts in api-reference.md before selecting a function. Use workflows.md for projection/unprojection and transform pipelines, and troubleshooting.md when a shape, frame, dtype, or gradient check fails.
Module and export boundary
gradslam.geometry exports the projective functions from projutils:
homogenize_pointsunhomogenize_pointsproject_pointsunproject_pointsinverse_intrinsics
The package root also re-exports these projective names. Do not assume that
other geometry helpers are attributes of gradslam.geometry; import them from
their implementation modules explicitly:
from gradslam.geometry import project_points, unproject_points
from gradslam.geometry.geometryutils import (
cam2pixel,
compose_transforms_3d,
create_meshgrid,
relative_transformation,
transform_normals,
transform_pointcloud,
transform_pts_3d,
)
from gradslam.geometry.se3utils import se3_exp, so3_exp
se3_exp is specifically a direct se3utils import. The same is true of
so3_hat, se3_hat, and so3_exp. geometryutils also contains a second
implementation of homogeneous conversion plus transform and pixel-grid
helpers; importing from that module is intentional when using those helpers,
not an alternate package-level export.
Operating rules
- Name frames before multiplying. A transform
t_abintransform_pts_3d(pts_b, t_ab)maps coordinates expressed in framebto framea. Matrix compositioncompose_transforms_3d(t1, t2)computest1 @ t2, sot2is applied first. - Keep points in the last dimension. Projective points end in 3 or 4, pixels in 2 or homogeneous 3, and normals/Euclidean points in 3. Batched projective tensors retain all leading dimensions when the batching contract is satisfied.
- Use true camera intrinsics for unprojection.
unproject_pointstakes an inverse 3x3 matrix and a depth tensor with shape exactly equal to the pixel tensor without its last coordinate.inverse_intrinsicsis a fast pinhole inverse for the supported 3x3/4x4 layout, not a general matrix inverse. - Treat zero denominators deliberately. Homogeneous weights within
epsare left unscaled byunhomogenize_points; projected depth exactly equal to zero is divided by one. These guards avoid infinities but do not provide a physically meaningful point at infinity. - Do not detach geometry tensors. The routines are intended to remain in
the autograd graph. Avoid
.numpy(),.item()in the computational path, or in-place edits to leaf tensors requiring gradients. - Use rigid transforms for rigid helpers. The custom inverse in
inverse_transfom_3dassumes an orthogonal rotation. Userelative_transformation(..., orthogonal_rotations=False)when the input may be a general invertible homogeneous matrix. - Respect implementation quirks.
quaternion_to_rotation_matrixexpects(x, y, z, w)and flattens leading batch dimensions beyond one batch axis;normalize_pixel_coordscurrently applies the first image-size factor to both coordinates. See the API and troubleshooting references rather than silently correcting these behaviors in a caller.
Minimal decision tree
- Euclidean or homogeneous point conversion: use the exported
projutilsfunctions for public camera code; use thegeometryutilsversions only when a transform helper in that module is also required. - 3D camera points to pixels: use
project_pointswith a 4x4 projection matrix; it accepts(..., 3)or(..., 4)points. - Pixels and depth to camera points: use
unproject_pointswith a 3x3 inverse intrinsics matrix and matching depth shape. - Intrinsics inverse: use
inverse_intrinsicsfor the library's pinhole K layout, including the 4x4 form used by RGB-D structures. - Point/normal frame change: use
transform_pts_3dortransform_pointcloud; rotate normals without translation usingtransform_normals. - Relative poses: use
relative_transformationfor batched or general invertible poses; userelative_transform_3dfor matching rigid tensors. - Optimization update: use
se3_expon a six-vector ordered as(translation, rotation); it returns a 4x4 transform.
The bundled CPU smoke check is
scripts/geometry_smoke.py. It uses only deterministic in-memory tensors and
has no network, display, dataset, or GPU path.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).