ttnn.deallocate

ttnn.deallocate(tensor: ttnn.Tensor, force: bool = True) None

Releases the resources for ttnn.Tensor tensor explicitly.

Parameters:
  • tensor (ttnn.Tensor) – The tensor whose resources will be released.

  • force (bool, optional) – Whether to force deallocation, even if the buffer may have multiple references. Defaults to True.

Example

# Create a TT-NN tensor and deallocate its memory
ttnn_tensor = ttnn.rand((2, 3), dtype=ttnn.bfloat16, device=device)
ttnn.deallocate(ttnn_tensor)