mindspore.ops.Square

class mindspore.ops.Square(*args, **kwargs)[source]

Returns square of a tensor element-wise.

Inputs:
  • input_x (Tensor) - The input tensor whose dtype is number.

Outputs:

Tensor, has the same shape and dtype as the input_x.

Raises

TypeError – If input_x is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32)
>>> square = ops.Square()
>>> output = square(input_x)
>>> print(output)
[1. 4. 9.]
infer_value(x)[source]

Infer the value of input for Square.