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+DeadCodeEliminateto func until none of the enabled passes report a change.The two
enable_const_fold_*flags forward toConstFold’senable_context/enable_opknobs (ignored whenenable_const_fold=False). A common use isenable_const_fold_context=Falseto simplify boolean / numeric expressions while leavingwith-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.