nerfacc.inclusive_prod¶
- nerfacc.inclusive_prod(inputs, packed_info=None)¶
Inclusive Product that supports flattened tensor.
This function is equivalent to torch.cumprod(inputs, dim=-1), but allows for a flattened input tensor and a packed_info tensor that specifies the chunks in the flattened input.
- Parameters:
inputs (Tensor) – The tensor to be producted. Can be either a N-D tensor, or a flattened tensor with packed_info 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 product is computed along the last dimension. Default is None.
- Returns:
The inclusive product 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") >>> inclusive_prod(inputs, packed_info) tensor([1., 2., 3., 12., 60., 6., 42., 336., 3024.], device='cuda:0')