ttnn.tilize_with_val_padding

ttnn.tilize_with_val_padding(input_tensor: ttnn.Tensor, output_tensor_shape: shape, pad_value: number, *, memory_config: ttnn.MemoryConfig = None, dtype: data type = None, use_multicore: bool = True) ttnn.Tensor

Changes data layout of input tensor to TILE. Pads to specified shape with a user-provided value.

Input tensor must be on TT accelerator device, in ROW_MAJOR layout, and have BFLOAT16 data type.

Output tensor will be on TT accelerator device, in TILE layout, and have BFLOAT16 data type.

Parameters:
  • input_tensor (ttnn.Tensor) – the input tensor.

  • output_tensor_shape (shape) – Shape of the output tensor.

  • pad_value (number) – Value to pad the output tensor.

Keyword Arguments:
  • memory_config (ttnn.MemoryConfig, optional) – Memory configuration for the operation. Defaults to None.

  • dtype (data type, optional) – Data type of the output tensor. Defaults to None.

  • use_multicore (bool, optional) – Whether to use multicore. Defaults to True.

Returns:

ttnn.Tensor – the output tensor.

Example

# Create a tensor to tilize with value padding
input_tensor = ttnn.rand((1, 1, 64, 32), dtype=ttnn.bfloat16, layout=ttnn.ROW_MAJOR_LAYOUT, device=device)

# Tilize the tensor with value padding
tilized_tensor = ttnn.tilize_with_val_padding(input_tensor, output_tensor_shape=[1, 1, 64, 64], pad_value=0.0)
logger.info("Tilized Tensor with Value Padding Shape:", tilized_tensor.shape)