IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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

min

def min[dtype: DType, input_fn: def[width: Int, rank: Int](IndexList[rank]) capturing thin -> SIMD[dtype, width], output_fn: def[width: SIMDLength, rank: Int](IndexList[rank], SIMD[dtype, width]) capturing thin -> None, /, target: StringSlice[ImmStaticOrigin] = StringSlice("cpu"), *, reduce_dim: Int](input_shape: Coord, context: Optional[DeviceContext] = None)

Computes the min across the input and output shape.

This performs the min computation on the domain specified by input_shape, loading the inputs using the input_fn. The results are stored using the output_fn.

Parameters:

  • ​dtype (DType): The dtype of the input and output.
  • ​input_fn (def[width: Int, rank: Int](IndexList[rank]) capturing thin -> SIMD[dtype, width]): The function to load the input.
  • ​output_fn (def[width: SIMDLength, rank: Int](IndexList[rank], SIMD[dtype, width]) capturing thin -> None): The function to store the output.
  • ​target (StringSlice[ImmStaticOrigin]): The target to run on.
  • ​reduce_dim (Int): The axis to perform the min on.

Args:

Raises:

If the operation fails.

def min[dtype: DType](src: Span[Scalar[dtype]]) -> Scalar[dtype]

Computes the min element in a buffer.

Parameters:

  • ​dtype (DType): The dtype of the input.

Args:

Returns:

Scalar[dtype]: The minimum of the buffer elements.

Raises:

If the operation fails.

Was this page helpful?