mindspore.mint.abs

mindspore.mint.abs(input)[source]

Compute the absolute value of a tensor element-wise.

For complex input, computes the magnitude of each element.

\[out_i = |input_i|\]
Parameters:

input (Tensor) – The input tensor.

Returns:

Tensor with the same shape as input. If input has dtype complex64 or complex128, the output dtype is float32 or float64, respectively. Otherwise, the output dtype is the same as input.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> output = mindspore.mint.abs(mindspore.tensor([-1.0, 1.0, 0.0]))
>>> print(output)
[1. 1. 0.]