Open Yanni-Chen opened 1 year ago
hello @Yanni-chen , we have released a new speedup version, you could have a try:
pip install nni=3.0rc1
from nni.compression.pytorch.speedup.v2 import ModelSpeedup
Hello @J-shang, I installed the new version with pip install nni==3.0rc. However, when running 'from nni.compression.pytorch.speedup.v2 import ModelSpeedup', A new imported error occurred.
hello @Yanni-Chen , I think this may case by your typeguard version, could you reinstall typeguard
?
Hello @J-shang, I installed typeguard by 'conda install ypeguard'. Then, a RuntimeError reported
Describe the issue: I am trying to use NNI to prune and speed up the compressed model. However, when using ModelSpeedup, a Type error occurs. TypeError: Conv2d.forward() missing 1 required positional argument: 'input'
Environment:
Configuration:
I test the DNN models cloned from https://github.com/kuangliu/pytorch-cifar. The Resent18 models are trained with their own script.
Then, I use the following configures to prune the trained model
config_list = [{ 'sparsity_per_layer': sparsity,
'op_types': ['Conv2d', 'Linear'] }, { 'exclude': True, 'op_names': ['module.conv1', 'module. Linear'] }] pruner = L1NormPruner(model, configlist) , masks = pruner.compress() for name, mask in masks.items(): print(name, ' sparsity : ', '{:.2}'.format(mask['weight'].sum() / mask['weight'].numel())) pruner._unwrap_model() dummy_input = torch.rand(8, 3, 32, 32).to(next(model.parameters ()).device) ModelSpeedup(model, (dummy_input), masks).speedup_model()
The output log information is