mindspore.ops.abs
- mindspore.ops.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
complex64orcomplex128, the output dtype isfloat32orfloat64, respectively. Otherwise, the output dtype is the same as input.
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore >>> output = mindspore.ops.abs(mindspore.tensor([-1.0, 1.0, 0.0])) >>> print(output) [1. 1. 0.]