mindspore.ops.Square
- class mindspore.ops.Square(*args, **kwargs)[source]
Returns square of a tensor element-wise.
- Inputs:
x (Tensor) - The input tensor whose dtype is number. \((N,*)\) where \(*\) means ,any number of additional dimensions, its rank should less than 8.
- Outputs:
Tensor, has the same shape and dtype as the x.
- Raises
TypeError – If x is not a Tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32) >>> square = ops.Square() >>> output = square(x) >>> print(output) [1. 4. 9.]