Shortcuts

nerfacc.exclusive_sum

nerfacc.exclusive_sum(inputs, packed_info=None, indices=None)

Exclusive Sum that supports flattened tensor.

Similar to nerfacc.inclusive_sum(), but computes the exclusive sum.

Parameters:
  • inputs (Tensor) – The tensor to be summed. Can be either a N-D tensor, or a flattened tensor with either packed_info or indices specified.

  • packed_info (Optional[Tensor]) – A tensor of shape (n_rays, 2) that specifies the start and count of each chunk in the flattened input tensor, with in total n_rays chunks. If None, the input is assumed to be a N-D tensor and the sum is computed along the last dimension. Default is None.

  • indices (Optional[Tensor]) – A flattened tensor with the same shape as inputs.

Returns:

The exclusive sum with the same shape as the input tensor.

Return type:

Tensor

Example:

>>> inputs = torch.tensor([1., 2., 3., 4., 5., 6., 7., 8., 9.], device="cuda")
>>> packed_info = torch.tensor([[0, 2], [2, 3], [5, 4]], device="cuda")
>>> exclusive_sum(inputs, packed_info)
tensor([ 0.,  1.,  0.,  3.,  7.,  0.,  6., 13., 21.], device='cuda:0')