Skip to main content

function

cost_of

cost_of[fn_type: AnyRegType, func: $0]() -> OpCount

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 loads, stores, additions, comparisons, divisions, exponentiations, multiplications, multiply-adds and other MLIR operations in the function after elaboration.

Parameters:

  • fn_type (AnyRegType): The signature type of the function.
  • func ($0): The function to evaluate.

Returns:

The number of post-elaboration operations in the function.