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)
| 767 | |
| 768 | |
| 769 | def _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 | |
| 795 | def _make_ntuple(x: Any, n: int) -> tuple[Any, ...]: |
no outgoing calls
no test coverage detected
searching dependent graphs…