unsorted_segment_sum#
- ivy.unsorted_segment_sum(data, segment_ids, num_segments)[source]#
Compute the sum of elements along segments of an array. Segments are defined by an integer array of segment IDs.
- Parameters:
data (
Union
[Array
,NativeArray
]) – The array from which to gather values.segment_ids (
Union
[Array
,NativeArray
]) – Must be in the same size with the first dimension of data. Has to be of integer data type. The index-th element of segment_ids array is the segment identifier for the index-th element of data.num_segments (
Union
[int
,Array
,NativeArray
]) – An integer or array representing the total number of distinct segment IDs.
- Return type:
- Returns:
ret – The output array, representing the result of a segmented sum operation. For each segment, it computes the sum of values in data where segment_ids equals to segment ID.
- Array.unsorted_segment_sum(self, segment_ids, num_segments)[source]#
ivy.Array instance method variant of ivy.unsorted_segment_sum. This method simply wraps the function, and so the docstring for ivy.unsorted_segment_sum also applies to this method with minimal changes.
- Parameters:
self (
Array
) – The array from which to gather values.segment_ids (
Array
) – Must be in the same size with the first dimension of self. Has to be of integer data type. The index-th element of segment_ids array is the segment identifier for the index-th element of self.num_segments (
Union
[int
,Array
]) – An integer or array representing the total number of distinct segment IDs.
- Return type:
Array
- Returns:
ret – The output array, representing the result of a segmented sum operation. For each segment, it computes the sum of values in self where segment_ids equals to segment ID.
- Container.unsorted_segment_sum(self, segment_ids, num_segments)[source]#
ivy.Container instance method variant of ivy.unsorted_segment_sum. This method simply wraps the function, and so the docstring for ivy.unsorted_segment_sum also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input array or container from which to gather the input.segment_ids (
Container
) – Must be in the same size with the first dimension of self. Has to be of integer data type. The index-th element of segment_ids array is the segment identifier for the index-th element of self.num_segments (
Union
[int
,Container
]) – An integer or array representing the total number of distinct segment IDs.
- Returns:
ret – A container, representing the result of a segmented sum operation. For each segment, it computes the sum of values in self where segment_ids equals to segment ID.