For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
random_uniform
def random_uniform[dtype: DType, rank: Int, //, target: StringSlice[ImmStaticOrigin], OutputFn: def[width: SIMDLength, _rank: Int](idx: IndexList[_rank], val: SIMD[dtype, width]) -> None & ImplicitlyCopyable & RegisterPassable](shape: IndexList[rank], lower_bound: Scalar[dtype], upper_bound: Scalar[dtype], seed_ptr: Pointer[UInt64, ImmutAnyOrigin, _safe=False], ctx: DeviceContext, output_fn: OutputFn) where (eq OutputFn.dtype, dtype)
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. - βrank (
Int): The rank of the underlying buffer. - βtarget (
StringSlice[ImmStaticOrigin]): The target to run on. - βOutputFn (
def[width: SIMDLength, _rank: Int](idx: IndexList[_rank], val: SIMD[dtype, width]) -> None&ImplicitlyCopyable&RegisterPassable): The type of the function which stores the generated values.
Args:
- βshape (
IndexList[rank]): 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 (
Pointer[UInt64, ImmutAnyOrigin, _safe=False]): 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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!