MCPcopy
hub / github.com/pytorch/vision / _log_api_usage_once

Function _log_api_usage_once

torchvision/utils.py:769–792  ·  view source on GitHub ↗

Logs API usage(module and name) within an organization. In a large ecosystem, it's often useful to track the PyTorch and TorchVision APIs usage. This API provides the similar functionality to the logging module in the Python stdlib. It can be used for debugging purpose to log wh

(obj: Any)

Source from the content-addressed store, hash-verified

767
768
769def _log_api_usage_once(obj: Any) -> None:
770 """
771 Logs API usage(module and name) within an organization.
772 In a large ecosystem, it's often useful to track the PyTorch and
773 TorchVision APIs usage. This API provides the similar functionality to the
774 logging module in the Python stdlib. It can be used for debugging purpose
775 to log which methods are used and by default it is inactive, unless the user
776 manually subscribes a logger via the `SetAPIUsageLogger method <https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L114>`_.
777 Please note it is triggered only once for the same API call within a process.
778 It does not collect any data from open-source users since it is no-op by default.
779 For more information, please refer to
780 * PyTorch note: https://pytorch.org/docs/stable/notes/large_scale_deployments.html#api-usage-logging;
781 * Logging policy: https://github.com/pytorch/vision/issues/5052;
782
783 Args:
784 obj (class instance or method): an object to extract info from.
785 """
786 module = obj.__module__
787 if not module.startswith("torchvision"):
788 module = f"torchvision.internal.{module}"
789 name = obj.__class__.__name__
790 if isinstance(obj, FunctionType):
791 name = obj.__name__
792 torch._C._log_api_usage_once(f"{module}.{name}")
793
794
795def _make_ntuple(x: Any, n: int) -> tuple[Any, ...]:

Callers 15

__init__Method · 0.90
horizontal_flipFunction · 0.90
vertical_flipFunction · 0.90
resizeFunction · 0.90
affineFunction · 0.90
rotateFunction · 0.90
padFunction · 0.90
cropFunction · 0.90
perspectiveFunction · 0.90
elasticFunction · 0.90
center_cropFunction · 0.90
resized_cropFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…