mindspore.ops.Abs

class mindspore.ops.Abs(*args, **kwargs)[source]

Returns absolute value of a tensor element-wise.

outi=|xi|
Inputs:
  • x (Tensor) - The input tensor. The shape of tensor is (x1,x2,...,xR).

Outputs:

Tensor, has the same shape as the x.

Raises

TypeError – If x is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> x = Tensor(np.array([-1.0, 1.0, 0.0]), mindspore.float32)
>>> abs = ops.Abs()
>>> output = abs(x)
>>> print(output)
[1. 1. 0.]