mindspore.ops.addn
- mindspore.ops.addn(x)[source]
Computes addition of all input tensors element-wise.
All input tensors must have the same shape.
- Parameters
x (Union(tuple[Tensor], list[Tensor])) – A tuple or list composed of Tensor.
- Returns
Tensor, has the same shape and dtype as each Tensor of x.
- Raises
TypeError – If x is neither tuple nor list.
ValueError – If there are Tensors with different shapes in x.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([1, 2, 3]), mindspore.float32) >>> y = Tensor(np.array([4, 5, 6]), mindspore.float32) >>> output = ops.addn([x, y, x, y]) >>> print(output) [10. 14. 18.]