MCPcopy Index your code
hub / github.com/microsoft/TRELLIS / sparse_cat

Function sparse_cat

trellis/modules/sparse/basic.py:420–444  ·  view source on GitHub ↗

Concatenate a list of sparse tensors. Args: inputs (List[SparseTensor]): List of sparse tensors to concatenate.

(inputs: List[SparseTensor], dim: int = 0)

Source from the content-addressed store, hash-verified

418
419
420def sparse_cat(inputs: List[SparseTensor], dim: int = 0) -> SparseTensor:
421 """
422 Concatenate a list of sparse tensors.
423
424 Args:
425 inputs (List[SparseTensor]): List of sparse tensors to concatenate.
426 """
427 if dim == 0:
428 start = 0
429 coords = []
430 for input in inputs:
431 coords.append(input.coords.clone())
432 coords[-1][:, 0] += start
433 start += input.shape[0]
434 coords = torch.cat(coords, dim=0)
435 feats = torch.cat([input.feats for input in inputs], dim=0)
436 output = SparseTensor(
437 coords=coords,
438 feats=feats,
439 )
440 else:
441 feats = torch.cat([input.feats for input in inputs], dim=dim)
442 output = inputs[0].replace(feats)
443
444 return output
445
446
447def sparse_unbind(input: SparseTensor, dim: int) -> List[SparseTensor]:

Callers

nothing calls this directly

Calls 2

SparseTensorClass · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected