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)
| 406 | |
| 407 | |
| 408 | def 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 | |
| 420 | def sparse_cat(inputs: List[SparseTensor], dim: int = 0) -> SparseTensor: |
nothing calls this directly
no test coverage detected