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

top_k_shape

def top_k_shape(input: T, k: Scalar, axis: Scalar, sorted: Scalar[DType.bool]) -> IndexList[T.rank]

Computes the output shape for the mo.top_k graph op.

Args:

  • ​input (T): Input tensor to select the top-k values from.
  • ​k (Scalar): Number of largest elements to select along axis.
  • ​axis (Scalar): Dimension along which to select the top-k elements.
  • ​sorted (Scalar[DType.bool]): Whether to sort the selected elements in descending order.

Returns:

IndexList[T.rank]: The output shape after selecting the top-k values along axis.

Was this page helpful?