Skip to content

Commit 329b978

Browse files
authored
Extend _log_api_usage_once to work for overwritten classes (#6237)
* Make `_log_api_usage_once` work for overwritten classes * Change module prefix to `torchvision.internal`
1 parent b19ced9 commit 329b978

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

torchvision/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,10 @@ def _log_api_usage_once(obj: Any) -> None:
562562
Args:
563563
obj (class instance or method): an object to extract info from.
564564
"""
565-
if not obj.__module__.startswith("torchvision"):
566-
return
565+
module = obj.__module__
566+
if not module.startswith("torchvision"):
567+
module = f"torchvision.internal.{module}"
567568
name = obj.__class__.__name__
568569
if isinstance(obj, FunctionType):
569570
name = obj.__name__
570-
torch._C._log_api_usage_once(f"{obj.__module__}.{name}")
571+
torch._C._log_api_usage_once(f"{module}.{name}")

0 commit comments

Comments
 (0)