reduce_subarrays_sum(values, row_splits, name=None)¶
Computes the sum for each subarray in a flat vector of arrays.
The start and end of the subarrays are defined by an exclusive prefix sum. Zero length subarrays are allowed as shown in the following example:
import open3d.ml.tf as ml3d ml3d.ops.reduce_subarrays_sum( values = [1,2,3,4], row_splits=[0,2,2,4] # defines 3 subarrays with starts and ends 0-2,2-2,2-4 ) # returns [3,0,7] # or with pytorch import torch import open3d.ml.torch as ml3d ml3d.ops.reduce_subarrays_sum( values = torch.Tensor([1,2,3,4]), row_splits=torch.LongTensor([0,2,2,4]) # defines 3 subarrays with starts and ends 0-2,2-2,2-4 ) # returns [3,0,7]
values – A Tensor. Must be one of the following types: int32, int64, float32, float64. Linear memory which stores the values for all arrays.
row_splits – A Tensor of type int64. Defines the start and end of each subarray. This is an exclusive prefix sum with 0 as the first element and the length of values as additional last element. If there are N subarrays the length of this vector is N+1.
name – A name for the operation (optional).
A Tensor. Has the same type as values. The sum of each subarray. The sum of an empty subarray is 0. sums is a zero length vector if values is a zero length vector.