ttnn.format_input_tensor
- ttnn.format_input_tensor(input: ttnn._ttnn.tensor.Tensor, device: ttnn._ttnn.device.IDevice, padded_shape: tt::tt_metal::SimpleShape, pad_value: float, target_layout: ttnn._ttnn.tensor.Layout, target_mem_config: Optional[ttnn._ttnn.tensor.MemoryConfig] = None) ttnn._ttnn.tensor.Tensor
-
Formats tensor to target layout and pads to padded shape.
- Parameters:
-
input (ttnn.Tensor) – Input tensor to format.
device (ttnn.device.Device) – Device where the tensor will be moved.
padded_shape (ttnn.Shape) – Desired shape of the tensor.
pad_value (float) – Value to pad with.
target_layout (ttnn.Layout) – Desired tensor layout.
target_mem_config (ttnn.MemoryConfig, optional) – Desired memory config. Defaults to None.
- Returns:
-
ttnn.Tensor – Formatted tensor.
Note
This functionality is planned for deprecation in the future.
Example
>>> input_tensor = ttnn.ones([1, 2, 2, 2], dtype=ttnn.bfloat16, layout=ttnn.ROW_MAJOR_LAYOUT) >>> padded_tensor = ttnn.format_input_tensor(input_tensor, device=device, padded_shape=[1, 2, 4, 4], pad_value=0.0, target_layout=ttnn.TILE_LAYOUT, output_mem_config)