@tf_export('math.abs', 'abs')
@dispatch.add_dispatch_support
def abs(x, name=None):
    'Computes the absolute value of a tensor.\n\n  Given a tensor `x` of complex numbers, this operation returns a tensor of type\n  `float32` or `float64` that is the absolute value of each element in `x`. All\n  elements in `x` must be complex numbers of the form \\\\(a + bj\\\\). The\n  absolute value is computed as \\\\( \\sqrt{a^2 + b^2}\\\\).  For example:\n  ```python\n  x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]])\n  tf.abs(x)  # [5.25594902, 6.60492229]\n  ```\n\n  Args:\n    x: A `Tensor` or `SparseTensor` of type `float16`, `float32`, `float64`,\n      `int32`, `int64`, `complex64` or `complex128`.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `Tensor` or `SparseTensor` the same size and type as `x` with absolute\n      values.\n    Note, for `complex64` or `complex128` input, the returned `Tensor` will be\n      of type `float32` or `float64`, respectively.\n  '
    with ops.name_scope(name, 'Abs', [x]) as name:
        x = ops.convert_to_tensor(x, name='x')
        if x.dtype.is_complex:
            return gen_math_ops.complex_abs(x, Tout=x.dtype.real_dtype, name=name)
        return gen_math_ops._abs(x, name=name)
Computes the absolute value of a tensor.

Given a tensor `x` of complex numbers, this operation returns a tensor of type
`float32` or `float64` that is the absolute value of each element in `x`. All
elements in `x` must be complex numbers of the form \\(a + bj\\). The
absolute value is computed as \\( \sqrt{a^2 + b^2}\\).  For example:
```python
x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]])
tf.abs(x)  # [5.25594902, 6.60492229]
```

Args:
  x: A `Tensor` or `SparseTensor` of type `float16`, `float32`, `float64`,
    `int32`, `int64`, `complex64` or `complex128`.
  name: A name for the operation (optional).

Returns:
  A `Tensor` or `SparseTensor` the same size and type as `x` with absolute
    values.
  Note, for `complex64` or `complex128` input, the returned `Tensor` will be
    of type `float32` or `float64`, respectively.
@tf_export('math.abs', 'abs')
@dispatch.add_dispatch_support
def abs(x, name=None):
    'Computes the absolute value of a tensor.\n\n  Given a tensor `x` of complex numbers, this operation returns a tensor of type\n  `float32` or `float64` that is the absolute value of each element in `x`. All\n  elements in `x` must be complex numbers of the form \\\\(a + bj\\\\). The\n  absolute value is computed as \\\\( \\sqrt{a^2 + b^2}\\\\).  For example:\n  ```python\n  x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]])\n  tf.abs(x)  # [5.25594902, 6.60492229]\n  ```\n\n  Args:\n    x: A `Tensor` or `SparseTensor` of type `float16`, `float32`, `float64`,\n      `int32`, `int64`, `complex64` or `complex128`.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `Tensor` or `SparseTensor` the same size and type as `x` with absolute\n      values.\n    Note, for `complex64` or `complex128` input, the returned `Tensor` will be\n      of type `float32` or `float64`, respectively.\n  '
    with ops.name_scope(name, 'Abs', [x]) as name:
        x = ops.convert_to_tensor(x, name='x')
        if x.dtype.is_complex:
            return gen_math_ops.complex_abs(x, Tout=x.dtype.real_dtype, name=name)
        return gen_math_ops._abs(x, name=name)