ttnn.full
- ttnn.full = Operation(python_fully_qualified_name='ttnn.full', function=<ttnn._ttnn.operations.creation.full_t object>, preprocess_golden_function_inputs=<function default_preprocess_golden_function_inputs>, golden_function=<function _golden_function_full>, postprocess_golden_function_outputs=<function default_postprocess_golden_function_outputs>, is_cpp_operation=True, is_experimental=False)
-
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)