Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
UltralyticsAssistant committed May 31, 2024
1 parent 790ad97 commit 12c3fb4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions thop/profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from thop.rnn_hooks import *
from thop.vision.basic_hooks import *

Expand Down Expand Up @@ -56,8 +55,11 @@
nn.SyncBatchNorm: count_normalization,
}


def profile_origin(model, inputs, custom_ops=None, verbose=True, report_missing=False):
"""Profiles a PyTorch model's operations and parameters by applying custom or default hooks and returns total operations and parameters."""
"""Profiles a PyTorch model's operations and parameters by applying custom or default hooks and returns total
operations and parameters.
"""
handler_collection = []
types_collection = set()
if custom_ops is None:
Expand Down Expand Up @@ -94,9 +96,7 @@ def add_hooks(m):
print(f"[INFO] Register {fn.__qualname__}() for {m_type}.")
else:
if m_type not in types_collection and report_missing:
prRed(
f"[WARN] Cannot find rule for {m_type}. Treat it as zero Macs and zero Params."
)
prRed(f"[WARN] Cannot find rule for {m_type}. Treat it as zero Macs and zero Params.")

if fn is not None:
handler = m.register_forward_hook(fn)
Expand Down Expand Up @@ -177,9 +177,7 @@ def add_hooks(m: nn.Module):
print(f"[INFO] Register {fn.__qualname__}() for {m_type}.")
else:
if m_type not in types_collection and report_missing:
prRed(
f"[WARN] Cannot find rule for {m_type}. Treat it as zero Macs and zero Params."
)
prRed(f"[WARN] Cannot find rule for {m_type}. Treat it as zero Macs and zero Params.")

if fn is not None:
handler_collection[m] = (
Expand Down

0 comments on commit 12c3fb4

Please sign in to comment.