diff --git a/thop/profile.py b/thop/profile.py index 4b98364..7db16bd 100644 --- a/thop/profile.py +++ b/thop/profile.py @@ -1,3 +1,5 @@ +import copy + from distutils.version import LooseVersion from thop.vision.basic_hooks import * @@ -151,6 +153,7 @@ def add_hooks(m): def profile(model: nn.Module, inputs, custom_ops=None, verbose=True): + model = copy.deepcopy(model) handler_collection = {} types_collection = set() if custom_ops is None: