function
save
save(tensor_dict: TensorDict, path: Path) -> object
Saves a collection of tensors to a file.
The file is saved in a binary format that's specific to MAX. You can then
load the checkpoint with
load()
.
For example:
from max.graph.checkpoint import save, TensorDict
from tensor import Tensor, TensorShape
def write_to_disk():
tensors = TensorDict()
tensors.set("x", Tensor[DType.int32](TensorShape(1, 2, 2), 1, 2, 3, 4))
tensors.set("y", Tensor[DType.float32](TensorShape(10, 5), -1.23))
save(tensors, "/path/to/checkpoint.maxckpt")
Args:
- tensor_dict (
TensorDict
): Tensors to save. - path (
Path
): The location to save the checkpoint file. You can use whatever filename and file extension you want.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
😔 What went wrong?