Sparse operators¶
reindex_sparse is the exact-support operation for decoder and context
branches. It keeps target row order and coordinate identity, drops source-only
rows, and fills target-only rows without routing through a pooling kernel.
prune keeps explicit row indices in caller order. prune_mask is the
boolean-mask form and preserves feature gradients through selected rows.
sparse_from_coordinates(..., duplicate_reduction='mean') performs an
unweighted feature mean for exact duplicate integer coordinates. Reduced
coordinates retain their first-occurrence order.
- torch_lattice.operators.cat(inputs, *, join='inner')[source]¶
- Return type:
- Parameters:
inputs (list[SparseTensor])
join (Literal['inner', 'left', 'right', 'outer'])
- torch_lattice.operators.generative_add(a, b)[source]¶
- Return type:
- Parameters:
a (SparseTensor)
b (SparseTensor)
- torch_lattice.operators.prune(input, rows)[source]¶
Keep sparse rows in caller-supplied order.
- Return type:
- Parameters:
input (SparseTensor)
rows (Tensor)
- torch_lattice.operators.prune_mask(input, mask)[source]¶
Keep sparse rows selected by a boolean mask.
- Return type:
- Parameters:
input (SparseTensor)
mask (Tensor)
- torch_lattice.operators.reindex_sparse(input, target, *, fill=0.0)[source]¶
Gather
inputfeatures onto the exact row order oftarget.- Return type:
- Parameters:
input (SparseTensor)
target (SparseTensor)
fill (float)
- torch_lattice.operators.sparse_add(lhs, rhs, *, join='outer', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
lhs (SparseTensor)
rhs (SparseTensor)
join (Literal['inner', 'left', 'right', 'outer'])
lhs_fill (float)
rhs_fill (float)
- torch_lattice.operators.sparse_binary(lhs, rhs, op, *, join='outer', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
lhs (SparseTensor)
rhs (SparseTensor)
op (Literal['add', 'sub', 'mul', 'maximum', 'minimum'])
join (Literal['inner', 'left', 'right', 'outer'])
lhs_fill (float)
rhs_fill (float)
- torch_lattice.operators.sparse_cat(inputs, *, join='inner')[source]¶
- Return type:
- Parameters:
inputs (list[SparseTensor])
join (Literal['inner', 'left', 'right', 'outer'])
- torch_lattice.operators.sparse_from_coordinates(coords, feats, *, stride=1, spatial_range=None, batch_counts=None, duplicate_reduction='none')[source]¶
Construct a sparse tensor with explicit duplicate-row semantics.
- torch_lattice.operators.sparse_maximum(lhs, rhs, *, join='inner', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
lhs (SparseTensor)
rhs (SparseTensor)
join (Literal['inner', 'left', 'right', 'outer'])
lhs_fill (float)
rhs_fill (float)
- torch_lattice.operators.sparse_minimum(lhs, rhs, *, join='inner', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
lhs (SparseTensor)
rhs (SparseTensor)
join (Literal['inner', 'left', 'right', 'outer'])
lhs_fill (float)
rhs_fill (float)
- torch_lattice.operators.sparse_mul(lhs, rhs, *, join='inner', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
lhs (SparseTensor)
rhs (SparseTensor)
join (Literal['inner', 'left', 'right', 'outer'])
lhs_fill (float)
rhs_fill (float)
- torch_lattice.operators.sparse_sub(lhs, rhs, *, join='outer', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
lhs (SparseTensor)
rhs (SparseTensor)
join (Literal['inner', 'left', 'right', 'outer'])
lhs_fill (float)
rhs_fill (float)