ttnn.from_device

ttnn.from_device(tensor: ttnn.Tensor, blocking: bool | None = True, *, cq_id: int | None = 0) ttnn.Tensor

Copy tensor from device to host.

Parameters:
  • tensor (ttnn.Tensor) – the tensor to be copied from device to host.

  • blocking (bool, optional) – whether the operation should be blocked until the copy is complete. Defaults to True.

Keyword Arguments:

cq_id (int, optional) – the command queue ID to use. Defaults to 0.

Returns:

ttnn.Tensor – the host tensor copy.

Example

>>> device = ttnn.open_device(0)
>>> tensor = ttnn.from_torch(torch.randn((10, 64, 32), dtype=torch.bfloat16))
>>> device_tensor = ttnn.to_device(tensor=tensor, device=device)
>>> # non-blocking mode
>>> host_tensor = ttnn.from_device(tensor=device_tensor, blocking=False)