<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/distribution/distribution_lib.py#L154-L233) |

A cluster of computation devices for distributed computation.

    tf.keras.distribution.DeviceMesh(
        shape, axis_names, devices=None
    )

This API is aligned with `jax.sharding.Mesh`, which represents the
computation devices in the global context.

See more details in [jax.sharding.Mesh](https://jax.readthedocs.io/en/latest/jax.sharding.html#jax.sharding.Mesh).

<br />

<br />

<br />

| ## Args ||
|---|---|
| `shape` | tuple of list of integers. The shape of the overall `DeviceMesh`, e.g. `(8,)` for a data parallel only distribution, or `(4, 2)` for a model+data parallel distribution. |
| `axis_names` | List of string. The logical name of the each axis for the `DeviceMesh`. The length of the `axis_names` should match to the rank of the `shape`. The `axis_names` will be used to match/create the `TensorLayout` when distribute the data and variables. |
| `devices` | Optional list of devices. Defaults to all the available devices locally from [`keras.distribution.list_devices()`](https://www.tensorflow.org/api_docs/python/tf/keras/distribution/list_devices). |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `axis_names` | <br /> <br /> |
| `backend_mesh` | <br /> <br /> |
| `devices` | <br /> <br /> |
| `shape` | <br /> <br /> |

<br />