mindspore.ops.unsorted_segment_prod

View Source On Gitee
mindspore.ops.unsorted_segment_prod(x, segment_ids, num_segments)[source]

Compute the product of the input tensor along segments.

The following figure shows the calculation process of unsorted_segment_prod:

../../_images/UnsortedSegmentProd.png

Note

  • If the segment_id i is absent in the segment_ids, then output[i] will be filled with 1.

  • The segment_ids must be non-negative tensor.

Parameters
  • x (Tensor) – The input tensor.

  • segment_ids (Tensor) – Indicate the segment to which each element belongs.

  • num_segments (Union[int, Tensor], optional) – Number of segments, it can be an int or 0-D tensor.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> x = mindspore.tensor([[1, 2, 3], [4, 5, 6], [4, 2, 1]])
>>> segment_ids = mindspore.tensor([0, 1, 0])
>>> num_segments = 2
>>> mindspore.ops.unsorted_segment_prod(x, segment_ids, num_segments)
Tensor(shape=[2, 3], dtype=Int64, value=
[[4, 4, 3],
 [4, 5, 6]])