ttnn.manual_seed
- ttnn.manual_seed(seeds: uint32_t or ttnn.Tensor, *, device: ttnn.MeshDevice | None, user_ids: uint32_t or ttnn.Tensor | None, sub_core_grids: optional)
-
Sets a seed to pseudo random number generators (PRNGs) on the specified device.
This operation allows users to either set a single seed value to all PRNGs in the device, or to specify potentially different seed values to PRNGs at the cores assigned to the provided user IDs.
- Parameters:
-
seeds (uint32_t or ttnn.Tensor) – A single integer seed or a tensor of seeds to initialize the random number generator.
- Keyword Arguments:
-
device (ttnn.MeshDevice, optional) – The device on which to set the manual seed. Provided only if user_ids is uint32_t or None.
user_ids (uint32_t or ttnn.Tensor, optional) – An optional user ID or tensor of user IDs associated with the seeds.
sub_core_grids (optional) – Custom core range set must be provided for multi-user execution. Core IDs are constrained to numbers 0 to 31.
- Returns:
-
Tensor (ttnn.Tensor) – An empty tensor, as this operation does not produce a meaningful output. To be changed in the future.
Note
Supported dtypes and layout for seeds tensor values:
Dtypes
Layouts
UINT32
ROW_MAJOR_LAYOUT
Supported dtypes and layout for user_ids tensor values:
Dtypes
Layouts
UINT32
ROW_MAJOR_LAYOUT
Example
# Set manual seed with scalar seed value for all cores ttnn.manual_seed(seeds=42, device=device) # Set manual seed for specific core ttnn.manual_seed(seeds=42, device=device, user_ids=7) # Set manual seed with tensor of seeds and tensor of user IDs # Maps user_id to seed value e.g., user_id 0 -> seed 42, user_id 1 -> seed 1, user_id 2 -> seed 4 seed_tensor = ttnn.from_torch( torch.Tensor([42, 1, 4]), dtype=ttnn.uint32, layout=ttnn.Layout.ROW_MAJOR, device=device ) user_id_tensor = ttnn.from_torch( torch.Tensor([0, 1, 2]), dtype=ttnn.uint32, layout=ttnn.Layout.ROW_MAJOR, device=device ) ttnn.manual_seed(seeds=seed_tensor, user_ids=user_id_tensor)