# tf.experimental.dtensor.name_based_restore

<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/save_restore.py#L100-L173) |

Restores from checkpoint_prefix to name based DTensors.

    tf.experimental.dtensor.name_based_restore(
        mesh: https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/experimental/dtensor/Mesh,
        checkpoint_prefix: str,
        name_tensor_dict: Dict[str, Union[tensor_lib.Tensor, tf_variables.Variable]]
    )

It is required to have already-initialized DTensor variables that have same
shape/dtype for the tensors being restored.

Also, we currently only support a named based restore on a single mesh.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `mesh` | The single mesh that all Tensors would be restored to. |
| `checkpoint_prefix` | The prefix of checkpoint to be restored. |
| `name_tensor_dict` | A ordered dictionary of tensor_names to a DTensor. The DTensor shape/dtype must match the tensors being saved/restored for now. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A dictionary of name to its restored DTensor value. ||

<br />