Mojo function
product
product[t: IntTuple[origin]](tuple: RuntimeTuple[t, element_type=element_type]) -> Int
Computes the product of all elements in the RuntimeTuple.
This function multiplies all scalar values in the tuple, including those in nested tuples after flattening. This is commonly used to calculate the total size of a tensor from its shape.
Parameters:
- t (
IntTuple): The IntTuple type parameter of the input RuntimeTuple.
Args:
- tuple (
RuntimeTuple): The inputRuntimeTuple.
Returns:
Int: The product of all scalar elements in the tuple.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!