Expose evaluate_spherical_harmonics in Python bindings#431
Conversation
Add tests for new bindings Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
There was a problem hiding this comment.
Pull request overview
This PR exposes the evaluate_spherical_harmonics function as a standalone Python binding, enabling users to efficiently reuse spherical harmonics evaluation for custom Gaussian splatting pipelines. This is particularly useful for workflows that need to reuse projection results when rasterizing multiple quantities, such as in GARfVDB segmentation.
Changes:
- Added Python binding for
evaluate_spherical_harmonicsin C++ with proper documentation - Added comprehensive unit tests covering various degrees, gradient flow, masking, and edge cases
- Updated type stub files and module exports to expose the new function
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/python/GaussianSplatBinding.cpp |
Adds Python binding with lambda wrapper that calls the C++ autograd function, includes comprehensive docstring |
fvdb/_fvdb_cpp.pyi |
Adds type stub for the C++ binding with proper type annotations |
fvdb/__init__.pyi |
Adds type stub for the public API |
fvdb/__init__.py |
Imports and exports the new function in the module's __all__ list |
tests/unit/test_gaussian_splat_3d.py |
Adds comprehensive test suite with 13 test cases covering basic functionality, gradient flow, masking, edge cases, and different configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tions is not provided for SH degree>0 Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
…or does not have a device' error is thrown when 'save_for_backward' is called Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
…th eval SH use in GaussianSplat3d Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
matthewdcong
left a comment
There was a problem hiding this comment.
Looks good to me, thanks!
This PR provides a python binding for
evaluate_spherical_harmonicsas a standalone function as well as add pytests for the functionality.This is useful in particular pipelines, for instance GARfVDB segmentation, where we want to be efficient about reusing projection results when rasterizing multiple times for different quantities. For instance, to reduce the time it takes to perform trilinear sampling during inference of the model, we can reduce the number of points we sample by only sampling points which are in frustum, not very small, etc. (i.e. the projected
radii<=0). After grid feature sampling, we then could reuse the projection results (often expensive) if we could construct a renderable quantity of the new, higher channel count features and substitute this quantity in theProjectedGaussianSplats. However, to do that we need to perform spherical harmonic evaluation. Instead of writing an equivalent utility function in python, it seems more sensible to expose the functionality we've already written/tested.