Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Improve Iterative Pruning: Verify Pruning Status Before Training #368

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ if isinstance(imp, tp.importance.GroupTaylorImportance):
loss = model(example_inputs).sum() # A dummy loss, please replace this line with your loss function and data!
loss.backward() # before pruner.step()

pruner.step()
macs, nparams = tp.utils.count_ops_and_params(model, example_inputs)
# finetune the pruned model here
# finetune(model)
# ...
if pruner.step():
macs, nparams = tp.utils.count_ops_and_params(model, example_inputs)
# finetune the pruned model here
# finetune(model)
# ...
```
#### Global Pruning

Expand Down
5 changes: 5 additions & 0 deletions torch_pruning/pruner/algorithms/metapruner.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,15 @@ def step(self, interactive=False)-> typing.Union[typing.Generator, None]:
if interactive: # yield groups for interactive pruning
return pruning_method()
else:
pruned = False
for group in pruning_method():
group.prune()
pruned = True
# print("gg")
# exit(0)
return pruned



def manual_prune(self, layer, pruning_fn, pruning_ratios_or_idxs):
if isinstance(pruning_ratios_or_idxs, float):
Expand Down