Scheduling

FPy’s scheduling language allows users to transform FPy functions using various small and reusable strategies. These strategies can be combined to create more complex transformations.

The available strategies are found in the fpy2.strategies module:

fpy2.strategies.simplify(func: Function, *, enable_const_fold: bool = True, enable_const_fold_context: bool = True, enable_const_fold_op: bool = True, enable_copy_prop: bool = True, enable_dead_code_elim: bool = True) Function

Apply ConstFold + CopyPropagate + DeadCodeEliminate to func until none of the enabled passes report a change.

The two enable_const_fold_* flags forward to ConstFold’s enable_context / enable_op knobs (ignored when enable_const_fold=False). A common use is enable_const_fold_context=False to simplify boolean / numeric expressions while leaving with-block contexts untouched.

fpy2.strategies.split(func: Function, factor: int | str, where: int | None = None, *, strategy: SplitLoopStrategy = SplitLoopStrategy.STRICT, temp_id: str = 't', outer_id: str = 'i', inner_id: str = 'i')
fpy2.strategies.unroll_for(func: Function, where: int | None = None, times: int = 1, *, strategy: ForUnrollStrategy = ForUnrollStrategy.PEEL, temp_id: str = 't', len_id: str = 'n', idx_id: str = 'i') Function

Unroll for loops in the function.

Parameters:
  • where (int | None) – The index of the for loop to unroll. If None, unroll all for loops.

  • times (int) – The number of times to unroll the loop.

fpy2.strategies.unroll_while(func: Function, where: int | None = None, times: int = 1) Function

Unroll while loops in the function.

Parameters:
  • func (Function) – The function to transform.

  • where (int | None) – The index of the while loop to unroll. If None, unroll all while loops.

  • times (int) – The number of times to unroll the loop.

Returns:

The transformed function.

Return type:

Function