ttnn.full

ttnn.full(shape: ttnn.Shape, fill_value: float, dtype: ttnn.DataType | None = None, layout: ttnn.Layout | None = None, device: ttnn.Device | ttnn.MeshDevice | None = None, memory_config: ttnn.MemoryConfig | None = None, output_tensor: ttnn.Tensor | None = None, queue_id: int | None = 0) ttnn.Tensor

Creates a tensor of the specified shape and fills it with the specified scalar value.

Parameters:
  • shape (ttnn.Shape) – The shape of the tensor.

  • fill_value (float) – The value to fill the tensor with.

  • 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.

  • output_tensor (ttnn.Tensor, optional) – Preallocated output tensor. Defaults to None.

  • queue_id (int, optional) – command queue id. Defaults to 0.

Note

ROW_MAJOR_LAYOUT requires last dimension (shape[-1]) to be a multiple of 2 with dtype BFLOAT16 or UINT16. TILE_LAYOUT requires width (shape[-1]) and height (shape[-2]) dimension to be multiple of 32.

Returns:

ttnn.Tensor – A filled tensor of specified shape and value.

Example

>>> filled_tensor = ttnn.full(shape=[2, 2], fill_value=7.0, dtype=ttnn.bfloat16)
>>> print(filled_tensor)
ttnn.Tensor([[[[7.0,  7.0],
                [7.0,  7.0]]]], shape=Shape([2, 2]), dtype=DataType::BFLOAT16, layout=Layout::ROW_MAJOR)