mindspore.ops.accumulate_n

View Source On AtomGit
mindspore.ops.accumulate_n(x)[source]

ops.accumulate_n is deprecated from version 2.8.0 and will be removed in a future version, please use mindspore.ops.addn() instead.

Return the element-wise sum of all input tensors.

mindspore.ops.accumulate_n() is similar to mindspore.ops.addn(), but accumulate_n will not wait for all of its inputs to be ready before summing, which is able to reduce peak memory.

Parameters

x (Union(tuple[Tensor], list[Tensor])) – List of tensors or tuple of tensors.

Returns

Tensor

Supported Platforms:

Deprecated

Examples

>>> import mindspore
>>> x = mindspore.tensor([1, 2, 3], mindspore.float32)
>>> y = mindspore.tensor([4, 5, 6], mindspore.float32)
>>> output = mindspore.ops.accumulate_n([x, y, x, y])
>>> print(output)
[10. 14. 18.]