Skip to content

Commit dbbf31e

Browse files
committed
add docstring for _log_api_usage_once
1 parent 59c723c commit dbbf31e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

torchvision/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,21 @@ def _generate_color_palette(num_masks: int):
388388

389389

390390
def _log_api_usage_once(obj: Any) -> None:
391+
392+
"""
393+
Logs API usage(module and name) within an organization.
394+
In a large ecosystem, it's often useful to track the PyTorch and
395+
TorchVision APIs usage. This function is triggered once for a API call
396+
within a process. By default, no logs is generated(see https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L104).
397+
Users can subscribe to API usage events by registering instrumentation
398+
handler with `SetAPIUsageLogger`.
399+
For more information, please refer to
400+
* PyTorch note: https://pytorch.org/docs/stable/notes/large_scale_deployments.html#api-usage-logging;
401+
* Logging policy: https://github.com/pytorch/vision/issues/5052;
402+
403+
Args:
404+
obj (class instance or method): an object to extract info from.
405+
"""
391406
if not obj.__module__.startswith("torchvision"):
392407
return
393408
name = obj.__class__.__name__

0 commit comments

Comments
 (0)