ttnn.reallocate

ttnn.reallocate(tensor: ttnn.Tensor, memory_config: ttnn.MemoryConfig | None = None) ttnn.Tensor

Deallocates device tensor and returns a reallocated tensor.

Parameters:
  • tensor (ttnn.Tensor) – the input tensor.

  • memory_config (ttnn.MemoryConfig, optional) – memory configuration for the reallocated tensor. Defaults to None.

Returns:

ttnn.Tensor – the reallocated tensor.

Example

>>> device_id = 0
>>> device = ttnn.open_device(device_id=device_id)
>>> tensor = ttnn.to_device(ttnn.from_torch(torch.randn((10, 64, 32), dtype=torch.bfloat16)), device)
>>> new_tensor = ttnn.reallocate(tensor, memory_config=my_memory_config)