# tf.experimental.dtensor.run_on

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/dtensor/python/api.py#L67-L86) |

Runs enclosed functions in the DTensor device scope. (deprecated)

    @contextlib.contextmanager
    tf.experimental.dtensor.run_on(
        mesh: https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/experimental/dtensor/Mesh
    )

> [!WARNING]
> **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use [`dtensor.default_mesh`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/experimental/dtensor/default_mesh) scope instead.

This function returns a scope. All the ops and tf.functions in this scope will
run on the DTensor device using the mesh provided.
This is useful for wrapping any tf.function that doesn't take a DTensor as
input but would like to produce DTensor as result. The scope will also make
sure all small constants be replicated as DTensor.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `mesh` | A Mesh instance to extract a default mesh from. |

<br />

<br />

<br />

<br />

| ## Yields ||
|---|---|
| A context in which all ops and tf.functions will run on the DTensor device. ||

<br />