# tf.contrib.framework.smart_cond

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/framework/smart_cond.py#L27-L59) |

Return either `true_fn()` if predicate `pred` is true else `false_fn()`.

    tf.contrib.framework.smart_cond(
        pred, true_fn=None, false_fn=None, name=None
    )

If `pred` is a bool or has a constant value, we return either `true_fn()`
or `false_fn()`, otherwise we use [`tf.cond`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/cond) to dynamically route to both.

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `pred` | A scalar determining whether to return the result of `true_fn` or `false_fn`. |
| `true_fn` | The callable to be performed if pred is true. |
| `false_fn` | The callable to be performed if pred is false. |
| `name` | Optional name prefix when using [`tf.cond`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/cond). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Tensors returned by the call to either `true_fn` or `false_fn`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If `true_fn` or `false_fn` is not callable. |

<br />