mindspore.numpy.sqrt(x, dtype=None)[source]

Returns the non-negative square-root of an array, element-wise.


Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported. On GPU, the supported dtypes are np.float16 and np.float32.

  • x (Tensor) – The values whose square-roots are required.

  • dtype (mindspore.dtype, optional) – Defaults to None. Overrides the dtype of the output Tensor.


Tensor or scalar, an array of the same shape as x, containing the positive square-root of each element in x. For negative elements, nan is returned. This is a scalar if x is a scalar.

Supported Platforms:

Ascend GPU CPU


>>> import mindspore.numpy as np
>>> x = np.arange(6).reshape(2, 3).astype('float32')
>>> x_squared = np.square(x)
>>> output = np.sqrt(x_squared)
>>> print(output)
[[ 0. 1. 2.]
[ 3. 4. 5.]]