Skip to main content

Mojo function

Idx

Idx(value: Int) -> RuntimeInt

Helper to create runtime indices.

Usage: Idx(5) creates a RuntimeInt with value 5.

Args:

  • ​value (Int): The integer value for the runtime index.

Returns:

RuntimeInt: A RuntimeInt instance with the specified value.

Idx[value: Int]() -> ComptimeInt[value]

Helper to create compile-time indices.

Usage: Idx5 creates a ComptimeInt with value 5.

Parameters:

  • ​value (Int): The compile-time integer value.

Returns:

ComptimeInt: A ComptimeInt instance with the specified compile-time value.

Idx(value: IntLiteral[value.value]) -> ComptimeInt[Int(#pop.cast_to_builtin<#pop.int_literal_convert<*"value.value`"> : !pop.scalar<index>>)]

Helper to create compile-time indices.

Usage: Idx5 creates a ComptimeInt with value 5.

Args:

  • ​value (IntLiteral): The compile-time integer value.

Returns:

ComptimeInt: A ComptimeInt instance with the specified compile-time value.

Idx(value: Scalar[value.dtype]) -> RuntimeInt[value.dtype] where value.dtype.is_integral()

Create a runtime index from a scalar value.

Args:

  • ​value (Scalar): The integer value for the runtime index.

Returns:

RuntimeInt: A RuntimeInt instance with the specified value.

Was this page helpful?