From dbbf31ec7d825a9fa14eb700b60e1beb2b5ee44e Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Tue, 25 Jan 2022 01:04:26 +0000 Subject: [PATCH 1/3] add docstring for _log_api_usage_once --- torchvision/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/torchvision/utils.py b/torchvision/utils.py index c5bc44fea2e..c0536849cc2 100644 --- a/torchvision/utils.py +++ b/torchvision/utils.py @@ -388,6 +388,21 @@ def _generate_color_palette(num_masks: int): 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 function is triggered once for a API call + within a process. By default, no logs is generated(see https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L104). + Users can subscribe to API usage events by registering instrumentation + handler with `SetAPIUsageLogger`. + 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"): return name = obj.__class__.__name__ From 9a02cecba090d3804a7ae276e2ff918d2d7b4c27 Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Tue, 25 Jan 2022 05:38:09 +0000 Subject: [PATCH 2/3] lint --- torchvision/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/torchvision/utils.py b/torchvision/utils.py index c0536849cc2..a7165f5e808 100644 --- a/torchvision/utils.py +++ b/torchvision/utils.py @@ -2,11 +2,11 @@ import pathlib import warnings 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 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"] @@ -394,9 +394,9 @@ def _log_api_usage_once(obj: Any) -> None: In a large ecosystem, it's often useful to track the PyTorch and TorchVision APIs usage. This function is triggered once for a API call within a process. By default, no logs is generated(see https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L104). - Users can subscribe to API usage events by registering instrumentation + Users can subscribe to API usage events by registering instrumentation handler with `SetAPIUsageLogger`. - For more information, please refer to + 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; From 66ade9b81b944a73e521be25299f7d17aa95c8bc Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Wed, 26 Jan 2022 00:35:07 +0000 Subject: [PATCH 3/3] rephrase --- torchvision/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/torchvision/utils.py b/torchvision/utils.py index a7165f5e808..9f76c3717cf 100644 --- a/torchvision/utils.py +++ b/torchvision/utils.py @@ -392,10 +392,12 @@ 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 function is triggered once for a API call - within a process. By default, no logs is generated(see https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L104). - Users can subscribe to API usage events by registering instrumentation - handler with `SetAPIUsageLogger`. + 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 `_. + 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;