ttnn.arange
- ttnn.arange(start: int = 0, end: int, step: int = 1, *, dtype: ttnn.DataType = ttnn.bfloat16, device: ttnn.Device | ttnn.MeshDevice = None, memory_config: ttnn.MemoryConfig = ttnn.DRAM_MEMORY_CONFIG, layout: ttnn.Layout = ttnn.ROW_MAJOR) ttnn.Tensor
-
Creates a tensor with values ranging from start (inclusive) to end (exclusive) with a specified step size. The data type, device, layout and memory configuration of the resulting tensor can be specified.
- Parameters:
-
start (int, optional)The start of the range. Defaults to 0.
end (int)The end of the range (exclusive).
step (int, optional)The step size between consecutive values. Defaults to 1.
- Keyword Arguments:
-
dtype (ttnn.DataType, optional)The data type of the tensor. Defaults to ttnn.bfloat16.
device (ttnn.Device | ttnn.MeshDevice, optional)The device where the tensor will be allocated. Defaults to None.
memory_config (ttnn.MemoryConfig, optional)The memory configuration for the tensor. Defaults to ttnn.DRAM_MEMORY_CONFIG.
layout (ttnn.Layout, optional)The tensor layout. Defaults to ttnn.ROW_MAJOR.
- Returns:
-
ttnn.TensorA tensor containing evenly spaced values within the specified range.
Note
Supported dtypes and layouts:
Dtypes
Layouts
BFLOAT16, FLOAT32, UINT16, UINT32, INT32
TILE, ROW_MAJOR
step must be non-zero, and its sign must match the direction from start to end.
Example
# Create a TT-NN tensor with values ranging from 0 to 9 tensor = ttnn.arange(start=0, end=10, step=2, dtype=ttnn.bfloat16, device=device) logger.info("TT-NN arange tensor:", tensor)