"src/vscode:/vscode.git/clone" did not exist on "599ed8681cf8ac8719109d8c3b033f8a333cc2b2"
Unverified Commit 2275c281 authored by Kai Zhang's avatar Kai Zhang Committed by GitHub
Browse files

add docstring for _log_api_usage_once (#5273)



* add docstring for _log_api_usage_once

* lint

* rephrase
Co-authored-by: default avatarVasilis Vryniotis <datumbox@users.noreply.github.com>
parent c9493885
...@@ -2,11 +2,11 @@ import math ...@@ -2,11 +2,11 @@ import math
import pathlib import pathlib
import warnings import warnings
from types import FunctionType from types import FunctionType
from typing import Any, Union, Optional, List, Tuple, BinaryIO from typing import Any, BinaryIO, List, Optional, Tuple, Union
import numpy as np import numpy as np
import torch import torch
from PIL import Image, ImageDraw, ImageFont, ImageColor from PIL import Image, ImageColor, ImageDraw, ImageFont
__all__ = ["make_grid", "save_image", "draw_bounding_boxes", "draw_segmentation_masks", "draw_keypoints"] __all__ = ["make_grid", "save_image", "draw_bounding_boxes", "draw_segmentation_masks", "draw_keypoints"]
...@@ -388,6 +388,23 @@ def _generate_color_palette(num_masks: int): ...@@ -388,6 +388,23 @@ def _generate_color_palette(num_masks: int):
def _log_api_usage_once(obj: Any) -> None: def _log_api_usage_once(obj: Any) -> None:
"""
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 which methods are used and by default it is inactive, unless the user
manually subscribes a logger via the `SetAPIUsageLogger method <https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L114>`_.
Please note it is triggered only once for the same API call within a process.
It does not collect any data from open-source users since it is no-op by default.
For more information, please refer to
* PyTorch note: https://pytorch.org/docs/stable/notes/large_scale_deployments.html#api-usage-logging;
* Logging policy: https://github.com/pytorch/vision/issues/5052;
Args:
obj (class instance or method): an object to extract info from.
"""
if not obj.__module__.startswith("torchvision"): if not obj.__module__.startswith("torchvision"):
return return
name = obj.__class__.__name__ name = obj.__class__.__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