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.
-
SubMConv3dResidualBlock–Residual block with a single \(3\times3\times3\) submanifold convolution: conv, norm, add the input, act.
SubMConv3dBlock
¶
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
¶
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
¶
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).
SubMConv3dResidualBlock
¶
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.