Skip to main content

Mojo function

product

product[dtype: DType](src: Span[Scalar[dtype], origin]) -> Scalar[dtype]

Computes the product of the buffer elements.

Parameters:

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

Args:

  • src (Span): The buffer.

Returns:

Scalar: The product of the buffer elements.

Raises:

If the operation fails.

product[dtype: DType, input_fn: fn[width: Int, rank: Int](IndexList[rank]) capturing -> SIMD[dtype, width], output_fn: fn[width: Int, rank: Int](IndexList[rank], SIMD[dtype, width]) capturing -> None, /, single_thread_blocking_override: Bool = False, target: StringSlice[StaticConstantOrigin] = "cpu"](input_shape: IndexList[size], reduce_dim: Int, context: DeviceContextPtr = DeviceContextPtr())

Computes the product across the input and output shape. This performs the product 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 (fn[width: Int, rank: Int](IndexList[rank]) capturing -> SIMD[dtype, width]): The function to load the input.
  • output_fn (fn[width: Int, rank: Int](IndexList[rank], SIMD[dtype, width]) capturing -> None): The function to store the output.
  • single_thread_blocking_override (Bool): If True, then the operation is run synchronously using a single thread.
  • target (StringSlice): The target to run on.

Args:

  • input_shape (IndexList): The input shape.
  • reduce_dim (Int): The axis to perform the product on.
  • context (DeviceContextPtr): The pointer to DeviceContext.

Was this page helpful?