mindspore.mint.square

mindspore.mint.square(input)[source]

Returns square of a tensor element-wise.

\[y_i = input_i ^ 2\]
Parameters

input (Tensor) – The input tensor with a dtype of Number.

Returns

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

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> input = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32)
>>> output = mint.square(input)
>>> print(output)
[1. 4. 9.]