autotuning

Module

Implements the autotune functionality.

You can import these APIs from the autotune package. For example:

from autotune import search

autotune

autotune[T: AnyType, *Ts: AnyType](value: T, values: !pop.pack<Ts>) -> T

Forks compilation to evaluate each of the provided values.

Parameters:

  • T (AnyType): The first value type.
  • Ts (*AnyType): The types of the rest of the parameters.

Args:

  • value (T): The first value in the pack.
  • values (!pop.pack<Ts>): The tail values.

Returns:

The value being used in the current compilation fork.

autotune_fork

autotune_fork[type: AnyType, *values: *"type"]()

Forks compilation to evaluate each of the provided values.

Return parameters: out: The value being used in the current compilation fork.

Parameters:

  • type (AnyType): The type of the parameters to be evaluated.
  • values (**"type"): A list of parameters to be evaluated.

cost_of

cost_of[fn_type: AnyType, func: fn_type]() -> Int

Count the number of operations in a function.

This function takes a function reference and estimates the ā€œcostā€ of invoking the function by counting the number of MLIR operations in the function after elaboration.

FIXME: This function should be marked @consteval or equivalent to prevent dynamic instantiation of kgen.cost_of.

Parameters:

  • fn_type (AnyType): The signature type of the function.
  • func (fn_type): The function to evaluate.

Returns:

The number of post-elaboration operations in the function.