For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
shape_div
shape_div[a_t: IntTuple, b_t: IntTuple](a: RuntimeTuple[a_t, element_type=a.element_type], b: RuntimeTuple[b_t, element_type=b.element_type]) -> RuntimeTuple[shape_div(a_t, b_t)]
Performs specialized shape division between RuntimeTuples.
This function implements a special division operation specifically designed for tensor shape calculations. Unlike standard division, it handles special cases:
- If shapes are directly divisible (a % b == 0), returns a standard division (a // b)
- If shapes are inversely divisible (b % a == 0), returns the signed reciprocal
- If shapes are incompatible, aborts with an error
This operation is essential for transformations between tensor layouts and computing broadcasting semantics.
Parameters:
Args:
- a (
RuntimeTuple[a_t, element_type=a.element_type]): The dividendRuntimeTuple. - b (
RuntimeTuple[b_t, element_type=b.element_type]): The divisorRuntimeTuple.
Returns:
RuntimeTuple[shape_div(a_t, b_t)]: A new RuntimeTuple containing the result of the shape division.