DeepVAC / deepvac

PyTorch Project Specification.
GNU General Public License v3.0
670 stars 104 forks source link

TypeError: 'Proxy' object cannot be interpreted as an integer #116

Open MHGL opened 3 years ago

MHGL commented 3 years ago

🐛 Bug

I get an error

To Reproduce

Steps to reproduce the behavior:

  1. code example
    
    import torch
    from torch.quantization import get_default_qconfig
    from torch.quantization.quantize_fx import prepare_fx

init module

class MyModule(torch.nn.Module): def init(self): super(MyModule, self).init() ...

def forward(self, x):
    for i in range(x.size(1)):
        x += 1
    return 

torch_model = MyModule().eval()

fx

s_qconfig_dict = {'': get_default_qconfig("fbgemm")} prepare_fx(torch_model, s_qconfig_dict)

2. stack traces
```python3
Traceback (most recent call last):
  File "mini_code.py", line 22, in <module>
    prepare_fx(torch_model, s_qconfig_dict)
  File "/opt/conda/lib/python3.8/site-packages/torch/quantization/quantize_fx.py", line 392, in prepare_fx
    return _prepare_fx(model, qconfig_dict, prepare_custom_config_dict)
  File "/opt/conda/lib/python3.8/site-packages/torch/quantization/quantize_fx.py", line 174, in _prepare_fx
    graph_module = GraphModule(model, tracer.trace(model))
  File "/opt/conda/lib/python3.8/site-packages/torch/fx/symbolic_trace.py", line 571, in trace
    self.create_node('output', 'output', (self.create_arg(fn(*args)),), {},
  File "mini_code.py", line 14, in forward
    for i in range(x.size(1)):
TypeError: 'Proxy' object cannot be interpreted as an integer

Expected behavior

Environment

xiaopengaia commented 3 years ago

How to solve it? I also met it ..... Thanks!

xiaopengaia commented 3 years ago

I get it, Thank you!

PHaiJun commented 2 years ago

I got a same error, how to solve it?

frothmoon commented 11 months ago

@xiaopengaia How to solve it? I also met it ..... Thanks!