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

Function sparse_batch_op

trellis/modules/sparse/basic.py:408–417  ·  view source on GitHub ↗

Broadcast a 1D tensor to a sparse tensor along the batch dimension then perform an operation. Args: input (torch.Tensor): 1D tensor to broadcast. target (SparseTensor): Sparse tensor to broadcast to. op (callable): Operation to perform after broadcasting. Defaul

(input: SparseTensor, other: torch.Tensor, op: callable = torch.add)

Source from the content-addressed store, hash-verified

406
407
408def sparse_batch_op(input: SparseTensor, other: torch.Tensor, op: callable = torch.add) -> SparseTensor:
409 """
410 Broadcast a 1D tensor to a sparse tensor along the batch dimension then perform an operation.
411
412 Args:
413 input (torch.Tensor): 1D tensor to broadcast.
414 target (SparseTensor): Sparse tensor to broadcast to.
415 op (callable): Operation to perform after broadcasting. Defaults to torch.add.
416 """
417 return input.replace(op(input.feats, sparse_batch_broadcast(input, other)))
418
419
420def sparse_cat(inputs: List[SparseTensor], dim: int = 0) -> SparseTensor:

Callers

nothing calls this directly

Calls 2

sparse_batch_broadcastFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected