ttnn.zeros
- ttnn.zeros(shape: ttnn.Shape, dtype: ttnn.DataType = None, layout: ttnn.Layout = None, device: ttnn.Device | ttnn.MeshDevice = None, memory_config: ttnn.MemoryConfig = None) ttnn.Tensor
-
Creates a tensor with the specified shape and fills it with the value of 0.0.
- Parameters:
-
shape (ttnn.Shape)The shape of the tensor.
dtype (ttnn.DataType, optional)The data type of the tensor. Defaults to None.
layout (ttnn.Layout, optional)The layout of the tensor. Defaults to None.
device (ttnn.Device | ttnn.MeshDevice, optional)The device on which the tensor will be allocated. Defaults to None.
memory_config (ttnn.MemoryConfig, optional)The memory configuration of the tensor. Defaults to None.
- Returns:
-
ttnn.TensorA tensor filled with 0.0.
Note
Supported dtypes and layouts:
Dtypes
Layouts
BFLOAT16, FLOAT32, BFLOAT8_B, BFLOAT4_B, UINT8, UINT16, UINT32, INT8, INT32
TILE, ROW_MAJOR
BFLOAT8_B and BFLOAT4_B are supported only on TILE layout. ROW_MAJOR requires last dimension to be a multiple of 2 with dtype BFLOAT16 or UINT16. TILE requires width and height dimensions to be multiples of 32.
Example
# Create a TT-NN tensor filled with zeros tensor = ttnn.zeros(shape=[2, 2], dtype=ttnn.bfloat16, layout=ttnn.ROW_MAJOR_LAYOUT, device=device) logger.info("TT-NN zeros tensor:", tensor)