Mojo function
prefix_product2
prefix_product2(a: IntTuple[origin], init: IntTuple[origin]) -> IntTuple
Implementation of exclusive prefix product computation.
Computes the exclusive prefix product of elements in the input IntTuple
.
For nested tuples, the function is applied recursively.
The function handles four cases:
- tuple-tuple: Apply
prefix_product2
element-wise when dimensions match - tuple-int: Apply
prefix_product2
to each element with updated init value. - int-tuple: Not allowed, will abort
- int-int: Return the init value
Note: If dimensions of tuple inputs don't match or if int-tuple case is encountered, abort() will be called.
Args:
- a (
IntTuple[origin]
): The inputIntTuple
to compute the prefix product for. - init (
IntTuple[origin]
): The initial value(s) for the prefix product.
Returns:
A new IntTuple
containing the exclusive prefix product of the input.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!