Unverified Commit 329b9789 authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

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`
parent b19ced92
...@@ -562,9 +562,10 @@ def _log_api_usage_once(obj: Any) -> None: ...@@ -562,9 +562,10 @@ def _log_api_usage_once(obj: Any) -> None:
Args: Args:
obj (class instance or method): an object to extract info from. obj (class instance or method): an object to extract info from.
""" """
if not obj.__module__.startswith("torchvision"): module = obj.__module__
return if not module.startswith("torchvision"):
module = f"torchvision.internal.{module}"
name = obj.__class__.__name__ name = obj.__class__.__name__
if isinstance(obj, FunctionType): if isinstance(obj, FunctionType):
name = obj.__name__ name = obj.__name__
torch._C._log_api_usage_once(f"{obj.__module__}.{name}") torch._C._log_api_usage_once(f"{module}.{name}")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment