mindspore.ops.SquareSumAll

View Source On Gitee
class mindspore.ops.SquareSumAll[source]

Returns the square sum of a tensor element-wise.

\[\begin{split}\left\{\begin{matrix}out_{x} = {\textstyle \sum_{0}^{N}} (x_{i})^2 \\out_{y} = {\textstyle \sum_{0}^{N}} (y_{i})^2 \end{matrix}\right.\end{split}\]

Note

SquareSumAll only supports float16 and float32 data type.

Inputs:
  • x (Tensor) - The input tensor. The data type must be float16 or float32. \((N, *)\) where \(*\) means, any number of additional dimensions.

  • y (Tensor) - The input tensor has the same type and shape as the x.

Outputs:
  • output_x (Tensor) - The same type as the x.

  • output_y (Tensor) - The same type as the x.

Raises
  • TypeError – If neither x nor y is a Tensor.

  • ValueError – If x and y are not the same shape.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> import mindspore
>>> import mindspore.ops as ops
>>> from mindspore import Tensor
>>> x = Tensor(np.array([0, 0, 2, 0]), mindspore.float32)
>>> y = Tensor(np.array([0, 0, 2, 4]), mindspore.float32)
>>> square_sum_all = ops.SquareSumAll()
>>> output = square_sum_all(x, y)
>>> print(output)
(Tensor(shape=[], dtype=Float32, value= 4),
 Tensor(shape=[], dtype=Float32, value= 20))