ttnn.full_like
- ttnn.full_like(tensor: ttnn.Tensor, fill_value: float | int, 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 same shape as the input tensor and fills it with the specified scalar value. The data type, layout, device, and memory configuration of the resulting tensor can be specified.
- Parameters:
-
tensor (ttnn.Tensor) – The tensor to use as a template for the shape of the new tensor.
fill_value (float | int) – 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.
- Returns:
-
ttnn.Tensor – A filled tensor.
Example
>>> tensor = ttnn.zeros(shape=(2, 3), dtype=ttnn.bfloat16) >>> filled_tensor = ttnn.full_like(tensor, fill_value=5.0, dtype=ttnn.bfloat16) >>> print(filled_tensor) ttnn.Tensor([[[[5.0, 5.0, 5.0], [5.0, 5.0, 5.0]]]], shape=Shape([2, 3]), dtype=DataType::BFLOAT16, layout=Layout::ROW_MAJOR)