# tf.compat.v1.assert_greater

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/check_ops.py#L987-L993) |

Assert the condition `x > y` holds element-wise.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.debugging.assert_greater`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/assert_greater)

<br />

    tf.compat.v1.assert_greater(
        x, y, data=None, summarize=None, message=None, name=None
    )

<br />

## Migrate to TF2

<br />

> [!CAUTION]
> **Caution:** This API was designed for TensorFlow v1. Continue reading for details on how to migrate from this API to a native TensorFlow v2 equivalent. See the [TensorFlow v1 to TensorFlow v2 migration guide](https://www.tensorflow.org/guide/migrate) for instructions on how to migrate the rest of your code.

[`tf.compat.v1.assert_greater`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/compat/v1/assert_greater) is compatible with eager execution and
[`tf.function`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/function).
Please use [`tf.debugging.assert_greater`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/debugging/assert_greater) instead when migrating to TF2. Apart
from `data`, all arguments are supported with the same argument name.

If you want to ensure the assert statements run before the
potentially-invalid computation, please use [`tf.control_dependencies`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/control_dependencies),
as tf.function auto-control dependencies are insufficient for assert
statements.

#### Structural Mapping to Native TF2

Before:

    tf.compat.v1.assert_greater(
      x=x, y=y, data=data, summarize=summarize,
      message=message, name=name)

After:

    tf.debugging.assert_greater(
      x=x, y=y, message=message,
      summarize=summarize, name=name)

#### TF1 \& TF2 Usage Example

TF1:

    g = tf.Graph()
    with g.as_default():
      a = tf.compat.v1.placeholder(tf.float32, [2])
      b = tf.compat.v1.placeholder(tf.float32, [2])
      result = tf.compat.v1.assert_greater(a, b,
        message='"a > b" does not hold for the given inputs')
      with tf.compat.v1.control_dependencies([result]):
        sum_node = a + b
    sess = tf.compat.v1.Session(graph=g)
    val = sess.run(sum_node, feed_dict={a: [1, 2], b:[0, 1]})

TF2:

    a = tf.Variable([1, 2], dtype=tf.float32)
    b = tf.Variable([0, 1], dtype=tf.float32)
    assert_op = tf.debugging.assert_greater(a, b, message=
      '"a > b" does not hold for the given inputs')
    # When working with tf.control_dependencies
    with tf.control_dependencies([assert_op]):
      val = a + b

<br />

<br />

## Description

This condition holds if for every pair of (possibly broadcast) elements
`x[i]`, `y[i]`, we have `x[i] > y[i]`.
If both `x` and `y` are empty, this is trivially satisfied.

When running in graph mode, you should add a dependency on this operation
to ensure that it runs. Example of adding a dependency to an operation:

    with tf.control_dependencies([tf.compat.v1.assert_greater(x, y)]):
      output = tf.reduce_sum(x)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Numeric `Tensor`. |
| `y` | Numeric `Tensor`, same dtype as and broadcastable to `x`. |
| `data` | The tensors to print out if the condition is False. Defaults to error message and first few entries of `x`, `y`. |
| `summarize` | Print this many entries of each tensor. |
| `message` | A string to prefix to the default message. |
| `name` | A name for this operation (optional). Defaults to "assert_greater". |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Op that raises `InvalidArgumentError` if `x > y` is False. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `InvalidArgumentError` | if the check can be performed immediately and `x > y` is False. The check can be performed immediately during eager execution or if `x` and `y` are statically known. |

<br />