Sparse tensor

Batch views are derived from the coordinate batch column, while declared batch_counts or spatial_range preserve empty batches. The decomposed coordinate views omit the batch column and remain available after row-changing layers.

class torch_lattice.tensor.SparseTensor(feats, coords, stride=1, spatial_range=None, *, batch_counts=None, coord_manager=None, coord_key=None)[source]

Bases: object

Sparse feature value with explicit coordinate-support identity.

Coordinates have shape (N, 4) and use (batch, x, y, z) order. Features have shape (N, C) and share their row order with coordinates. Coordinate managers own support identity and cached sparse relations; feature-only transformations preserve that identity, while row-changing operations create a new coordinate key.

Parameters:
replace(*, feats)[source]

Return a feature replacement on the same coordinate support.

Return type:

SparseTensor

Parameters:

feats (Tensor)

with_coordinates(*, feats, coords, stride=None, spatial_range=<object object>, batch_counts=None)[source]

Return a value on newly created coordinate support.

Return type:

SparseTensor

Parameters:
cpu()[source]
Return type:

SparseTensor

cuda(device=None)[source]
Return type:

SparseTensor

Parameters:

device (device | int | None)

half()[source]
Return type:

SparseTensor

detach()[source]
Return type:

SparseTensor

to(device, *, non_blocking=False)[source]
Return type:

SparseTensor

Parameters:
dense()[source]
Return type:

Tensor

property batch_indices: Tensor

Batch column from coords.

property batch_rows: tuple[Tensor, ...]

Row indices grouped by coordinate batch value.

property decomposed_coordinates: tuple[Tensor, ...]

Spatial coordinates split by batch.

property decomposed_features: tuple[Tensor, ...]

Feature rows split by batch.

property decomposed_coordinates_and_features: tuple[tuple[Tensor, ...], tuple[Tensor, ...]]

Spatial coordinates and features split by batch.