Open gkrisp98 opened 1 year ago
hello @gkrisp98 , seems that the tuple unpacking goes wrong, 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
I tried to use speedup.v2 and I got this error:
TypeError Traceback (most recent call last)
[<ipython-input-11-3f9ced178c5c>](https://localhost:8080/#) in <cell line: 5>()
3 from nni.compression.pytorch.speedup.v2 import ModelSpeedup
4 model.eval()
----> 5 ModelSpeedup(model, torch.rand(1,3,28,28), masks).speedup_model()
8 frames
[/usr/local/lib/python3.10/dist-packages/nni/compression/pytorch/speedup/v2/model_speedup.py](https://localhost:8080/#) in __init__(self, model, dummy_input, masks_or_file, map_location, batch_dim, batch_size, customized_mask_updaters, customized_replacers, graph_module, garbage_collect_values, logger)
98 self.dummy_input = _normalize_input(dummy_input)
99 self.bound_model = model
--> 100 self.graph_module = graph_module if isinstance(graph_module, GraphModule) else concrete_trace(model, self.dummy_input)
101
102 super().__init__(self.graph_module, garbage_collect_values)
[/usr/local/lib/python3.10/dist-packages/nni/common/concrete_trace_utils/concrete_tracer.py](https://localhost:8080/#) in concrete_trace(root, concrete_args, use_operator_patch, operator_patch_backlist, forward_function_name, check_args, autowrap_leaf_function, autowrap_leaf_class, leaf_module, fake_middle_class, dce)
1473 tracer = ConcreteTracer()
1474
-> 1475 graph = tracer.trace(root,
1476 autowrap_leaf_function = autowrap_leaf_function,
1477 autowrap_leaf_class = autowrap_leaf_class,
[/usr/local/lib/python3.10/dist-packages/nni/common/concrete_trace_utils/concrete_tracer.py](https://localhost:8080/#) in trace(self, root, autowrap_modules, autowrap_leaf_function, autowrap_leaf_class, leaf_module, fake_middle_class, concrete_args, use_operator_patch, operator_patch_backlist, forward_function_name)
984 with OperatorPatcherContext(self, use_operator_patch, operator_patch_backlist):
985 self.create_node('output', 'output',
--> 986 (self.create_arg(OperatorPatcherContext.patch_run(fn, *args, *more_args, **kwargs)),),
987 {}, type_expr=fn.__annotations__.get('return', None))
988 finally:
[/usr/local/lib/python3.10/dist-packages/nni/common/concrete_trace_utils/operator_patcher.py](https://localhost:8080/#) in patch_run(func, *args, **kwargs)
287 with OperatorPatcherContext.ctx_tracer.do_temp_disable(True, True, True):
288 new_func = OperatorPatcherContext.ctx_patcher.patch_inner(func)
--> 289 return new_func(*args, **kwargs)
[/content/drive/MyDrive/EXTD_Pytorch-master2/EXTD_64.py](https://localhost:8080/#) in new_func(self, x)
185 self.priorbox = PriorBox(size, features_maps, cfg)
186 with torch.no_grad():
--> 187 self.priors = self.priorbox.forward()
188
189 loc = torch.cat([o.view(o.size(0), -1) for o in loc], 1)
[/usr/local/lib/python3.10/dist-packages/nni/common/concrete_trace_utils/operator_patcher.py](https://localhost:8080/#) in patch_run(func, *args, **kwargs)
287 with OperatorPatcherContext.ctx_tracer.do_temp_disable(True, True, True):
288 new_func = OperatorPatcherContext.ctx_patcher.patch_inner(func)
--> 289 return new_func(*args, **kwargs)
[/content/drive/MyDrive/EXTD_Pytorch-master2/layers/functions/prior_box.py](https://localhost:8080/#) in new_func(self)
49 mean += [cx, cy, s_kw, s_kh]
50
---> 51 output = torch.Tensor(mean).view(-1, 4)
52 if self.clip:
53 output.clamp_(max=1, min=0)
[/usr/local/lib/python3.10/dist-packages/nni/common/concrete_trace_utils/operator_patcher.py](https://localhost:8080/#) in patch_run(func, *args, **kwargs)
287 with OperatorPatcherContext.ctx_tracer.do_temp_disable(True, True, True):
288 new_func = OperatorPatcherContext.ctx_patcher.patch_inner(func)
--> 289 return new_func(*args, **kwargs)
[/usr/local/lib/python3.10/dist-packages/nni/common/concrete_trace_utils/concrete_proxy.py](https://localhost:8080/#) in __len__(self)
134 if insts[cur].opcode == self.op_call_ex:
135 # in executing func(..., *proxy)
--> 136 return _orig_len(self.value)
137 elif insts[cur].opcode == self.op_tuple_unpack_call:
138 # in executing func(*..., *proxy)
TypeError: object of type 'float' has no len()
Describe the issue:
Environment: Vs Code
Hi, I am trying to prune a face detector. I used the following code:
But, when I try to use ModeSpeedup using this code:
I get the following error:
Even though I get this error, the model seems to be pruned. What is this issue ? How does it affect the pruning of the model and is there any way to overcome it ? Thanks in advance