ttnn.deallocate
- ttnn.deallocate(tensor: ttnn.Tensor, force: bool | None = True) `None`
-
Deallocates device tensor. Releases the resources for ttnn.Tensor
tensor
explicitly.- Parameters:
-
tensor (ttnn.Tensor) – the input tensor.
force (bool, optional) – force deallocation even if the buffer may have multiple references. Defaults to True.
- Returns:
-
None – deallocates the 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) >>> tensor = ttnn.to_layout(tensor, layout=ttnn.TILE_LAYOUT) >>> ttnn.deallocate(tensor=tensor, force=False)