ttnn.empty

ttnn.empty(shape: List[int], dtype: ttnn.DataType = ttnn.bfloat16, layout: ttnn.Layout = ttnn.ROW_MAJOR, device: ttnn.Device | ttnn.MeshDevice, memory_config: ttnn.MemoryConfig = ttnn.DRAM_MEMORY_CONFIG) → ttnn.Tensor

Creates a device tensor with uninitialized values of the specified shape, data type, layout, and memory configuration.

Parameters:
  • shape (List[int])The shape of the tensor to be created.

  • dtype (ttnn.DataType, optional)The tensor data type. Defaults to ttnn.bfloat16.

  • layout (ttnn.Layout, optional)The tensor layout. Defaults to ttnn.ROW_MAJOR.

  • device (ttnn.Device | ttnn.MeshDevice)The device where the tensor will be allocated.

  • memory_config (ttnn.MemoryConfig, optional)The memory configuration for the operation. Defaults to ttnn.DRAM_MEMORY_CONFIG.

Returns:

ttnn.TensorThe output uninitialized tensor.

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.

Example

# Create an uninitialized TT-NN tensor with the specified shape and data type
tensor = ttnn.empty(shape=[2, 3], dtype=ttnn.bfloat16, device=device)
logger.info("TT-NN empty tensor shape:", tensor.shape)