ttnn.dump_tensor

ttnn.dump_tensor(file_name: str | pathlib.Path, tensor: ttnn.Tensor, *, mode: ttnn.DumpTensorMode | None) `None`

Dump tensor to a file.

Parameters:
  • file_name (str | pathlib.Path) – The file name.

  • tensor (ttnn.Tensor) – the tensor to be dumped.

Keyword Arguments:

mode (ttnn.DumpTensorMode, optional) –

How host-side distributed tensors are written. Defaults to DISTRIBUTED_GATHER.

  • DISTRIBUTED_GATHER: perform a host all-gather, write the full tensor from global rank 0 only, and synchronize with barriers. Use this for a single canonical file from a distributed tensor.

  • LOCAL: skip collectives and write the caller’s local shard only. In multi-host runs, each process must use a distinct file_name (for example a per-host cache path).

Returns:

None – tensor saved to a specified file.

Example

# Create a TT-NN tensor and dump its contents
ttnn_tensor = ttnn.rand((2, 3), dtype=ttnn.bfloat16, device=device)
ttnn.dump_tensor(file_name="ttnn_tensor.tensorbin", tensor=ttnn_tensor)