grid_pool
Grid-based point cloud pooling (downsampling).
Clusters points by quantized grid coordinates and reduces features via scatter operations. This is an alternative to code-space pooling (SerializedPooling) used in PTV3 Mode 2 (Sonata) and Mode 3 (Utonia).
Classes:
-
GridPoolβGrid-based downsampling that clusters points by quantized coordinates.
GridPool [source] ΒΆ
GridPool(
in_channels: int,
out_channels: int,
stride: int = 2,
bias: bool = True,
act: Union[str, Callable, None] = None,
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
reduce: str = "max",
)
Bases: Module
Grid-based downsampling that clusters points by quantized coordinates.
Divides pos_grid by stride, groups unique voxels via torch.unique, and reduces features with torch_geometric.utils.segment.
Parameters:
-
in_channels(int) βNumber of input feature channels.
-
out_channels(int) βNumber of output feature channels.
-
stride(int, default:2) βSpatial stride for grid quantization.
-
act(Union[str, Callable, None], default:None) βActivation layer applied after projection.
-
act_kwargs(Optional[Dict[str, Any]], default:None) βExtra arguments for the activation function.
-
act_first(bool, default:False) βApply activation before normalization.
-
norm(Union[str, Callable, None], default:None) βNormalization layer applied after projection.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βExtra arguments for the normalization layer.
-
reduce(str, default:'max') βScatter reduction (
"max","mean","sum","min").
Methods:
-
forwardβDownsample points by grid quantization.
forward [source] ΒΆ
forward(
x: Tensor,
pos_grid: Tensor,
batch: Tensor,
pos: Optional[Tensor] = None,
condition: Optional[str] = None,
) -> Tuple[
Tensor, Tensor, Tensor, Tensor, Optional[Tensor]
]
Downsample points by grid quantization.
Parameters:
-
x(Tensor) βPoint features of shape \((N, C_{in})\).
-
pos_grid(Tensor) βInteger grid coordinates of shape \((N, 3)\). Must be non-negative and pool to coordinates below \(2^{16}\): batch index and coordinates are bit-packed into a single int64 cluster key, so out-of-range coordinates would merge clusters across samples.
-
batch(Tensor) βBatch indices of shape \((N,)\).
-
pos(Optional[Tensor], default:None) βOptional real-valued positions of shape \((N, 3)\) to mean-pool alongside the features (e.g. for downstream rotary position embedding).
-
condition(Optional[str], default:None) βOptional condition name selecting the inner norm when the norm is a
PDNorm.
Returns:
-
TensorβTuple of
(x_pooled, pos_grid_pooled, batch_pooled, pooling_inverse, pos_pooled). -
Tensorβpooling_inversemaps each input point to its pooled cluster index. -
Tensorβpos_pooledisNonewhenposis not provided.