Skip to content

Commit

Permalink
add cuda method defs in base classes and octreemgr 🙄
Browse files Browse the repository at this point in the history
  • Loading branch information
true-real-michael committed Feb 5, 2024
1 parent 52d8b5c commit 0ce162d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
14 changes: 14 additions & 0 deletions octreelib/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ def map_leaf_points(self, function: Callable[[PointCloud], PointCloud]):
for voxel_coordinates in self.__octrees:
self.__octrees[voxel_coordinates].map_leaf_points(function)

def map_leaf_points_cuda(
self, function, n_blocks: int = 8, n_threads_per_block: int = 256
):
"""
transform point cloud in the node using the function
:param function: transformation function PointCloud -> PointCloud
:param n_blocks: Number of blocks for the CUDA kernel. (a power of 8)
:param n_threads_per_block: Number of threads for the CUDA kernel.
"""
for voxel_coordinates in self.__octrees:
self.__octrees[voxel_coordinates].map_leaf_points_cuda(
function, n_blocks, n_threads_per_block
)

def get_leaf_points(self, pose_number: int) -> List[Voxel]:
"""
:param pose_number: The desired pose number.
Expand Down
12 changes: 12 additions & 0 deletions octreelib/grid/grid_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ def map_leaf_points(self, function: Callable[[PointCloud], PointCloud]):
"""
pass

@abstractmethod
def map_leaf_points_cuda(
self, function, n_blocks: int = 8, n_threads_per_block: int = 256
):
"""
transform point cloud in the node using the function
:param function: transformation function PointCloud -> PointCloud
:param n_blocks: Number of blocks for the CUDA kernel. (a power of 8)
:param n_threads_per_block: Number of threads for the CUDA kernel.
"""
pass

@abstractmethod
def get_leaf_points(self, pose_number: int) -> List[Voxel]:
"""
Expand Down
10 changes: 10 additions & 0 deletions octreelib/octree/octree_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ def map_leaf_points(self, function: Callable[[PointCloud], PointCloud]):
"""
pass

@abstractmethod
def map_leaf_points_cuda(self, function, n_blocks, n_threads_per_block):
"""
transform point cloud in the node using the function
:param function: transformation function PointCloud -> PointCloud
:param n_blocks: Number of blocks for the CUDA kernel. (a power of 8)
:param n_threads_per_block: Number of threads for the CUDA kernel.
"""
pass

@abstractmethod
def get_leaf_points(self) -> List[Voxel]:
"""
Expand Down
22 changes: 22 additions & 0 deletions octreelib/octree_manager/octree_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ def map_leaf_points(
for pose_number in pose_numbers:
self._octrees[pose_number].map_leaf_points(function)

def map_leaf_points_cuda(
self,
function,
pose_numbers: Optional[List[int]] = None,
n_blocks: int = 8,
n_threads_per_block: int = 256,
):
"""
transform point cloud in the node using the function
:param function: transformation function PointCloud -> PointCloud
:param pose_numbers: List of pose numbers to filter
:param n_blocks: Number of blocks for the CUDA kernel. (a power of 8)
:param n_threads_per_block: Number of threads for the CUDA kernel.
"""
if pose_numbers is None:
pose_numbers = self._octrees.keys()

for pose_number in pose_numbers:
self._octrees[pose_number].map_leaf_points_cuda(
function, n_blocks, n_threads_per_block
)

def filter(
self,
filtering_criteria: List[Callable[[PointCloud], bool]],
Expand Down

0 comments on commit 0ce162d

Please sign in to comment.