ttnn.uniform

ttnn.uniform(input: ttnn.Tensor, from: float32 = 0, to: float32 = 1, *, memory_config: ttnn.MemoryConfig = None, compute_kernel_config: ttnn.DeviceComputeKernelConfig = None) ttnn.Tensor

Update in-place the input tensor with values drawn from the continuous uniform distribution 1 / (to - from).

Parameters:
  • input (ttnn.Tensor) – The tensor that provides the shape for the generated uniform tensor.

  • from (float32) – The lower bound of the uniform distribution. Defaults to 0.

  • to (float32) – The upper bound of the uniform distribution. Defaults to 1.

Keyword Arguments:
  • memory_config (ttnn.MemoryConfig, optional) – Memory configuration for the operation. Defaults to None.

  • compute_kernel_config (ttnn.DeviceComputeKernelConfig, optional) – Configuration for the compute kernel. Defaults to None.

Returns:

ttnn.Tensor – The input tensor with updated values drawn from the specified uniform distribution.

Example

>>> input = ttnn.to_device(ttnn.from_torch(torch.ones(3, 3), dtype=torch.bfloat16)), device=device)
>>> ttnn.uniform(input)