Mojo function
shape_div
shape_div(a: IntTuple[origin], b: IntTuple[origin]) -> IntTuple
Performs division operation between shape tuples.
Handles four cases:
- tuple-tuple: Performs shape_div element-wise when dimensions match
- tuple-int: Folds the division of b across each element of a
Example:
shape_div((4,5,6),40)->shape_div((1,5,6),10)->shape_div((1,1,6),2)->(1,1,3) - int-tuple: Returns
shape_div(a, product(b)) - int-int: Enforces the divisibility condition
a % b == 0 || b % a == 0when possible Returnsa / bwith rounding away from0(that is,1or-1whena < b)
Notes:
- When tuple sizes don't match in the tuple-tuple case,
abort()will be called. - When values are incompatible (neither divides the other) in the int-int
case,
abort()will be called.
Args:
Returns:
IntTuple: A new IntTuple containing the result of the division operation
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!