spconv_blocks
Sparse convolution blocks: submanifold, strided, and residual variants.
Classes:
-
SubMConv3dBlockβSubmanifold sparse 3D convolution followed by normalization and activation, on packed point features.
-
SparseConvBlockβSparse 3D convolution followed by normalization and activation.
-
SparseResidualBlockβPre-activation sparse residual block shared by the SPFormer and SphereFormer SpConv U-Nets.
-
SparseBasicBlockβResidual block of two submanifold sparse convolutions: conv, norm, act, conv, norm, add the input, act.
-
SubMConv3dResidualBlockβResidual block with a single \(3\times3\times3\) submanifold convolution: conv, norm, add the input, act.
SubMConv3dBlock [source] ΒΆ
SubMConv3dBlock(
in_channels: int,
out_channels: int,
kernel_size: int,
padding: int,
norm: Union[str, Callable, None] = None,
act: Union[str, Callable, None] = None,
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = True,
stem_indice_key: Optional[str] = None,
)
Bases: Module
Submanifold sparse 3D convolution followed by normalization and activation, on packed point features.
Unlike SparseConvBlock, this block takes and returns packed \((N, C)\) features: it builds the SparseConvTensor from pos and batch itself, so it drops into a point-based backbone as a conditional position embedding.
Parameters:
-
in_channels(int) βNumber of input channels.
-
out_channels(int) βNumber of output channels.
-
kernel_size(int) βConvolution kernel size.
-
padding(int) βConvolution padding.
-
norm(Union[str, Callable, None], default:None) βNormalization passed to
create_norm. -
act(Union[str, Callable, None], default:None) βActivation passed to
create_act. -
act_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the activation.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the normalization.
-
bias(bool, default:True) βWhether the convolution has a bias term.
-
stem_indice_key(Optional[str], default:None) βspconv index key for the convolution.
SparseConvBlock [source] ΒΆ
SparseConvBlock(
in_channels: int,
out_channels: int,
kernel_size: Union[int, Tuple[int, ...]],
*,
stride: Union[int, Tuple[int, ...]] = 1,
padding: Union[int, Tuple[int, ...]] = 0,
indice_key: str,
conv_type: str = "subm",
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
)
Bases: SparseSequential
Sparse 3D convolution followed by normalization and activation.
A subm (submanifold), spconv (regular, optionally strided), or inverseconv convolution over a SparseConvTensor, followed by normalization and activation on the features. As a SparseSequential subclass it drops directly into the sparse voxel backbones' convolution stacks.
Parameters:
-
in_channels(int) βNumber of input channels.
-
out_channels(int) βNumber of output channels.
-
kernel_size(Union[int, Tuple[int, ...]]) βConvolution kernel size.
-
stride(Union[int, Tuple[int, ...]], default:1) βConvolution stride (used by
spconv). -
padding(Union[int, Tuple[int, ...]], default:0) βConvolution padding (used by
spconv). -
indice_key(str) βspconv index key for the convolution.
-
conv_type(str, default:'subm') βOne of
subm,spconv, orinverseconv. -
norm(Union[str, Callable, None], default:'batch_norm') βNormalization passed to
create_norm. -
norm_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the normalization (e.g.
eps,momentum). -
act(Union[str, Callable, None], default:'relu') βActivation passed to
create_act. -
act_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the activation.
SparseResidualBlock [source] ΒΆ
SparseResidualBlock(
in_channels: int,
out_channels: int,
*,
indice_key: Optional[str] = None,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
)
Bases: SparseModule
Pre-activation sparse residual block shared by the SPFormer and SphereFormer SpConv U-Nets.
The convolutional branch applies \(\text{norm} \to \text{act} \to \text{conv} \to \text{norm} \to \text{act} \to \text{conv}\) over two \(3\times3\times3\) submanifold convolutions; the identity branch is nn.Identity when the channels match, else a \(1\times1\times1\) SubMConv3d projection.
Parameters:
-
in_channels(int) βNumber of input channels.
-
out_channels(int) βNumber of output channels.
-
indice_key(Optional[str], default:None) βspconv index key shared by the two submanifold convolutions.
-
act(Union[str, Callable, None], default:'relu') βActivation passed to
create_act. -
act_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the activation.
-
norm(Union[str, Callable, None], default:'batch_norm') βNormalization passed to
create_norm. -
norm_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the normalization (e.g.
eps,momentum).
SparseBasicBlock [source] ΒΆ
SparseBasicBlock(
in_channels: int,
out_channels: int,
kernel_size: int = 3,
bias: bool = False,
indice_key: Optional[str] = None,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
)
Bases: SparseModule
Residual block of two submanifold sparse convolutions: conv, norm, act, conv, norm, add the input, act.
A pointwise submanifold convolution projects the skip connection when the channel count changes.
Parameters:
-
in_channels(int) βNumber of input channels.
-
out_channels(int) βNumber of output channels.
-
kernel_size(int, default:3) βKernel size of the two submanifold convolutions.
-
bias(bool, default:False) βWhether the two submanifold convolutions carry a bias.
-
indice_key(Optional[str], default:None) βspconv index key shared by the two submanifold convolutions.
-
act(Union[str, Callable, None], default:'relu') βActivation passed to
create_act. -
act_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the activation.
-
norm(Union[str, Callable, None], default:'batch_norm') βNormalization passed to
create_norm. -
norm_kwargs(Optional[Dict[str, Any]], default:None) βExtra keyword arguments for the normalization.
SubMConv3dResidualBlock [source] ΒΆ
SubMConv3dResidualBlock(
channels: int,
*,
indice_key: str,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
)
Bases: SparseModule
Residual block with a single \(3\times3\times3\) submanifold convolution: conv, norm, add the input, act.
Parameters:
-
channels(int) βInput and output channels.
-
indice_key(str) βShared submanifold indice key.
-
act(Union[str, Callable, None], default:'relu') βActivation type or callable.
-
act_kwargs(Optional[Dict[str, Any]], default:None) βExtra activation arguments.
-
norm(Union[str, Callable, None], default:'batch_norm') βNormalization type or callable.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βExtra normalization arguments.