ttnn.manage_device
- ttnn.manage_device(device_id: int) Device
-
Context manager for opening and closing a device.
- Parameters:
-
device_id (int) – The device ID to open.
- Returns:
-
ttnn.device.Device – the opened device. The device will be closed automatically when the block is exited, even if an error occurs.
Example
>>> with manage_device(device_id=0) as device: >>> # Perform operations with the device >>> tensor = ttnn.zeros((2, 3), device=device) >>> print(tensor) ttnn.Tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])