Skip to main content
Log in

Mojo function

randint

randint[type: DType](ptr: UnsafePointer[SIMD[type, 1], 0, 0, alignof[::AnyType,__mlir_type.!kgen.target]() if triple_is_nvidia_cuda() else 1], size: Int, low: Int, high: Int)

Fills memory with uniform random in range [low, high].

Constraints:

The type should be integral.

Parameters:

  • type (DType): The dtype of the pointer.

Args:

  • ptr (UnsafePointer[SIMD[type, 1], 0, 0, alignof[::AnyType,__mlir_type.!kgen.target]() if triple_is_nvidia_cuda() else 1]): The pointer to the memory area to fill.
  • size (Int): The number of elements to fill.
  • low (Int): The minimal value for random.
  • high (Int): The maximal value for random.

Was this page helpful?