For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
random_uniform
def random_uniform[dtype: DType, //, OutputFn: def[width: SIMDLength](idx: Coord[**?], val: SIMD[dtype, width]) -> None & RegisterPassable & ImplicitlyCopyable](shape: Coord[*shape.element_types], lower_bound: Scalar[dtype], upper_bound: Scalar[dtype], seed_ptr: ImmPointer[UInt64, ImmutAnyOrigin], ctx: DeviceContext, output_fn: OutputFn)
Call output_fn with values generated from a uniform distribution on [lower_bound, upper_bound] for floating-point types or [lower_bound, upper_bound) for integer types.
Parameters:
- dtype (
DType): The data type to generate. - OutputFn (
def[width: SIMDLength](idx: Coord[**?], val: SIMD[dtype, width]) -> None&RegisterPassable&ImplicitlyCopyable): The type of the function which stores the generated values.
Args:
- shape (
Coord[*shape.element_types]): The shape of the output being stored into by output_fn. - lower_bound (
Scalar[dtype]): The lower bound on the uniform range. - upper_bound (
Scalar[dtype]): The upper bound on the uniform range. - seed_ptr (
ImmPointer[UInt64, ImmutAnyOrigin]): Pointer to a single uint64 in device memory containing the Philox seed. - ctx (
DeviceContext): The device context. - output_fn (
OutputFn): The function which stores the generated values.