Lyken17 / pytorch-OpCounter

Count the MACs / FLOPs of your PyTorch model.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RuntimeError: Can't add a new parameter

aizvorski opened this issue · comments

I'm trying to use thop on a module that is a loaded from file.

My code looks like this:

model = torch.jit.load(...)
x = ...
model(x) # this works

from thop import profile
profile(model, inputs=x) # this raises an exception
# RuntimeError: Can't add a new parameter after ScriptModule construction. Tried to add 'total_ops

What is happening - is it basically that the deserialized model is immutable and thop tries to modify it?

Is there a way around this?

Versions: thop 0.1.1 from pip, torch 1.13.0 and python 3.10.12 from conda