IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

shape_div

def 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:

  1. If shapes are directly divisible (a % b == 0), returns a standard division (a // b)
  2. If shapes are inversely divisible (b % a == 0), returns the signed reciprocal
  3. If shapes are incompatible, aborts with an error

This operation is essential for transformations between tensor layouts and computing broadcasting semantics.

Parameters:

  • ​a_t (IntTuple): Type of the first operand.
  • ​b_t (IntTuple): Type of the second operand.

Args:

Returns:

RuntimeTuple[shape_div(a_t, b_t)]: A new RuntimeTuple containing the result of the shape division.

Was this page helpful?