coreai_opt.pruning.config.ConstantSparsitySchedule¶
- class coreai_opt.pruning.config.ConstantSparsitySchedule[source]¶
Bases:
SparsityScheduleBaseStep function: zero before
begin_step,target_sparsityat and after.- begin_step¶
Step at which to switch from 0 to
target_sparsity. Default: 0.- Type:
int
- compute_sparsity(step_count, target_sparsity, prev_sparsity=None)[source]¶
Return the sparsity that should be applied at step_count.
- Parameters:
step_count (int) – The current step count of the pruner (monotonically increasing).
target_sparsity (float) – The final sparsity we want to reach at the end of the pruning schedule.
prev_sparsity (float | None) – Sparsity from the previous invocation. Schedules that don’t need this can ignore it; schedules that do (e.g.
PolynomialDecaySchedulewith anupdate_frequencygap) raiseValueErrorwhen omitted.
- Returns:
The sparsity level to apply at the current step.
- Return type:
float