Skip to content

Commit ae00103

Browse files
committed
Merge branch 'main' into datasets/shuffler
2 parents 974afe1 + eac3dc7 commit ae00103

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+91
-56
lines changed

torchvision/csrc/ops/deform_conv2d.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ at::Tensor deform_conv2d(
2020
int64_t groups,
2121
int64_t offset_groups,
2222
bool use_mask) {
23+
C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.deform_conv2d.deform_conv2d");
2324
static auto op = c10::Dispatcher::singleton()
2425
.findSchemaOrThrow("torchvision::deform_conv2d", "")
2526
.typed<decltype(deform_conv2d)>();

torchvision/csrc/ops/nms.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ at::Tensor nms(
99
const at::Tensor& dets,
1010
const at::Tensor& scores,
1111
double iou_threshold) {
12+
C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.nms.nms");
1213
static auto op = c10::Dispatcher::singleton()
1314
.findSchemaOrThrow("torchvision::nms", "")
1415
.typed<decltype(nms)>();

torchvision/csrc/ops/ps_roi_align.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ std::tuple<at::Tensor, at::Tensor> ps_roi_align(
1212
int64_t pooled_height,
1313
int64_t pooled_width,
1414
int64_t sampling_ratio) {
15+
C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.ps_roi_align.ps_roi_align");
1516
static auto op = c10::Dispatcher::singleton()
1617
.findSchemaOrThrow("torchvision::ps_roi_align", "")
1718
.typed<decltype(ps_roi_align)>();

torchvision/csrc/ops/ps_roi_pool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ std::tuple<at::Tensor, at::Tensor> ps_roi_pool(
1111
double spatial_scale,
1212
int64_t pooled_height,
1313
int64_t pooled_width) {
14+
C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.ps_roi_pool.ps_roi_pool");
1415
static auto op = c10::Dispatcher::singleton()
1516
.findSchemaOrThrow("torchvision::ps_roi_pool", "")
1617
.typed<decltype(ps_roi_pool)>();

torchvision/csrc/ops/roi_align.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ at::Tensor roi_align(
1616
bool aligned) // The flag for pixel shift
1717
// along each axis.
1818
{
19+
C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.roi_align.roi_align");
1920
static auto op = c10::Dispatcher::singleton()
2021
.findSchemaOrThrow("torchvision::roi_align", "")
2122
.typed<decltype(roi_align)>();

torchvision/csrc/ops/roi_pool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ std::tuple<at::Tensor, at::Tensor> roi_pool(
1111
double spatial_scale,
1212
int64_t pooled_height,
1313
int64_t pooled_width) {
14+
C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.roi_pool.roi_pool");
1415
static auto op = c10::Dispatcher::singleton()
1516
.findSchemaOrThrow("torchvision::roi_pool", "")
1617
.typed<decltype(roi_pool)>();

torchvision/datasets/vision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(
3535
transform: Optional[Callable] = None,
3636
target_transform: Optional[Callable] = None,
3737
) -> None:
38-
_log_api_usage_once("datasets", self.__class__.__name__)
38+
_log_api_usage_once(self)
3939
if isinstance(root, torch._six.string_classes):
4040
root = os.path.expanduser(root)
4141
self.root = root

torchvision/models/alexnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class AlexNet(nn.Module):
1919
def __init__(self, num_classes: int = 1000, dropout: float = 0.5) -> None:
2020
super().__init__()
21-
_log_api_usage_once("models", self.__class__.__name__)
21+
_log_api_usage_once(self)
2222
self.features = nn.Sequential(
2323
nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2),
2424
nn.ReLU(inplace=True),

torchvision/models/densenet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __init__(
163163
) -> None:
164164

165165
super().__init__()
166-
_log_api_usage_once("models", self.__class__.__name__)
166+
_log_api_usage_once(self)
167167

168168
# First convolution
169169
self.features = nn.Sequential(

torchvision/models/detection/generalized_rcnn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class GeneralizedRCNN(nn.Module):
2727

2828
def __init__(self, backbone: nn.Module, rpn: nn.Module, roi_heads: nn.Module, transform: nn.Module) -> None:
2929
super().__init__()
30-
_log_api_usage_once("models", self.__class__.__name__)
30+
_log_api_usage_once(self)
3131
self.transform = transform
3232
self.backbone = backbone
3333
self.rpn = rpn

torchvision/models/detection/retinanet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def __init__(
337337
topk_candidates=1000,
338338
):
339339
super().__init__()
340-
_log_api_usage_once("models", self.__class__.__name__)
340+
_log_api_usage_once(self)
341341

342342
if not hasattr(backbone, "out_channels"):
343343
raise ValueError(

torchvision/models/detection/ssd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def __init__(
182182
positive_fraction: float = 0.25,
183183
):
184184
super().__init__()
185-
_log_api_usage_once("models", self.__class__.__name__)
185+
_log_api_usage_once(self)
186186

187187
self.backbone = backbone
188188

torchvision/models/detection/ssdlite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(
120120
min_depth: int = 16,
121121
):
122122
super().__init__()
123-
_log_api_usage_once("models", self.__class__.__name__)
123+
_log_api_usage_once(self)
124124

125125
assert not backbone[c4_pos].use_res_connect
126126
self.features = nn.Sequential(

torchvision/models/efficientnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def __init__(
170170
norm_layer (Optional[Callable[..., nn.Module]]): Module specifying the normalization layer to use
171171
"""
172172
super().__init__()
173-
_log_api_usage_once("models", self.__class__.__name__)
173+
_log_api_usage_once(self)
174174

175175
if not inverted_residual_setting:
176176
raise ValueError("The inverted_residual_setting should not be empty")

torchvision/models/googlenet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(
3939
dropout_aux: float = 0.7,
4040
) -> None:
4141
super().__init__()
42-
_log_api_usage_once("models", self.__class__.__name__)
42+
_log_api_usage_once(self)
4343
if blocks is None:
4444
blocks = [BasicConv2d, Inception, InceptionAux]
4545
if init_weights is None:

torchvision/models/inception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(
3737
dropout: float = 0.5,
3838
) -> None:
3939
super().__init__()
40-
_log_api_usage_once("models", self.__class__.__name__)
40+
_log_api_usage_once(self)
4141
if inception_blocks is None:
4242
inception_blocks = [BasicConv2d, InceptionA, InceptionB, InceptionC, InceptionD, InceptionE, InceptionAux]
4343
if init_weights is None:

torchvision/models/mnasnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class MNASNet(torch.nn.Module):
9898

9999
def __init__(self, alpha: float, num_classes: int = 1000, dropout: float = 0.2) -> None:
100100
super().__init__()
101-
_log_api_usage_once("models", self.__class__.__name__)
101+
_log_api_usage_once(self)
102102
assert alpha > 0.0
103103
self.alpha = alpha
104104
self.num_classes = num_classes

torchvision/models/mobilenetv2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __init__(
111111
112112
"""
113113
super().__init__()
114-
_log_api_usage_once("models", self.__class__.__name__)
114+
_log_api_usage_once(self)
115115

116116
if block is None:
117117
block = InvertedResidual

torchvision/models/mobilenetv3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def __init__(
151151
dropout (float): The droupout probability
152152
"""
153153
super().__init__()
154-
_log_api_usage_once("models", self.__class__.__name__)
154+
_log_api_usage_once(self)
155155

156156
if not inverted_residual_setting:
157157
raise ValueError("The inverted_residual_setting should not be empty")

torchvision/models/optical_flow/raft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def __init__(self, *, feature_encoder, context_encoder, corr_block, update_block
440440
If ``None`` (default), the flow is upsampled using interpolation.
441441
"""
442442
super().__init__()
443-
_log_api_usage_once("models", self.__class__.__name__)
443+
_log_api_usage_once(self)
444444

445445
self.feature_encoder = feature_encoder
446446
self.context_encoder = context_encoder

torchvision/models/regnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def __init__(
310310
activation: Optional[Callable[..., nn.Module]] = None,
311311
) -> None:
312312
super().__init__()
313-
_log_api_usage_once("models", self.__class__.__name__)
313+
_log_api_usage_once(self)
314314

315315
if stem_type is None:
316316
stem_type = SimpleStemIN

torchvision/models/resnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(
174174
norm_layer: Optional[Callable[..., nn.Module]] = None,
175175
) -> None:
176176
super().__init__()
177-
_log_api_usage_once("models", self.__class__.__name__)
177+
_log_api_usage_once(self)
178178
if norm_layer is None:
179179
norm_layer = nn.BatchNorm2d
180180
self._norm_layer = norm_layer

torchvision/models/segmentation/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class _SimpleSegmentationModel(nn.Module):
1313

1414
def __init__(self, backbone: nn.Module, classifier: nn.Module, aux_classifier: Optional[nn.Module] = None) -> None:
1515
super().__init__()
16-
_log_api_usage_once("models", self.__class__.__name__)
16+
_log_api_usage_once(self)
1717
self.backbone = backbone
1818
self.classifier = classifier
1919
self.aux_classifier = aux_classifier

torchvision/models/segmentation/lraspp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
self, backbone: nn.Module, low_channels: int, high_channels: int, num_classes: int, inter_channels: int = 128
3939
) -> None:
4040
super().__init__()
41-
_log_api_usage_once("models", self.__class__.__name__)
41+
_log_api_usage_once(self)
4242
self.backbone = backbone
4343
self.classifier = LRASPPHead(low_channels, high_channels, num_classes, inter_channels)
4444

torchvision/models/shufflenetv2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(
100100
inverted_residual: Callable[..., nn.Module] = InvertedResidual,
101101
) -> None:
102102
super().__init__()
103-
_log_api_usage_once("models", self.__class__.__name__)
103+
_log_api_usage_once(self)
104104

105105
if len(stages_repeats) != 3:
106106
raise ValueError("expected stages_repeats as list of 3 positive ints")

torchvision/models/squeezenet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
3636
class SqueezeNet(nn.Module):
3737
def __init__(self, version: str = "1_0", num_classes: int = 1000, dropout: float = 0.5) -> None:
3838
super().__init__()
39-
_log_api_usage_once("models", self.__class__.__name__)
39+
_log_api_usage_once(self)
4040
self.num_classes = num_classes
4141
if version == "1_0":
4242
self.features = nn.Sequential(

torchvision/models/vgg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(
3737
self, features: nn.Module, num_classes: int = 1000, init_weights: bool = True, dropout: float = 0.5
3838
) -> None:
3939
super().__init__()
40-
_log_api_usage_once("models", self.__class__.__name__)
40+
_log_api_usage_once(self)
4141
self.features = features
4242
self.avgpool = nn.AdaptiveAvgPool2d((7, 7))
4343
self.classifier = nn.Sequential(

torchvision/models/video/resnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def __init__(
209209
zero_init_residual (bool, optional): Zero init bottleneck residual BN. Defaults to False.
210210
"""
211211
super().__init__()
212-
_log_api_usage_once("models", self.__class__.__name__)
212+
_log_api_usage_once(self)
213213
self.inplanes = 64
214214

215215
self.stem = stem()

torchvision/ops/boxes.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def nms(boxes: Tensor, scores: Tensor, iou_threshold: float) -> Tensor:
3434
Tensor: int64 tensor with the indices of the elements that have been kept
3535
by NMS, sorted in decreasing order of scores
3636
"""
37-
_log_api_usage_once("ops", "nms")
37+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
38+
_log_api_usage_once(nms)
3839
_assert_has_ops()
3940
return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
4041

@@ -63,7 +64,8 @@ def batched_nms(
6364
Tensor: int64 tensor with the indices of the elements that have been kept by NMS, sorted
6465
in decreasing order of scores
6566
"""
66-
_log_api_usage_once("ops", "batched_nms")
67+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
68+
_log_api_usage_once(batched_nms)
6769
# Benchmarks that drove the following thresholds are at
6870
# https://github.com/pytorch/vision/issues/1311#issuecomment-781329339
6971
if boxes.numel() > (4000 if boxes.device.type == "cpu" else 20000) and not torchvision._is_tracing():
@@ -122,7 +124,8 @@ def remove_small_boxes(boxes: Tensor, min_size: float) -> Tensor:
122124
Tensor[K]: indices of the boxes that have both sides
123125
larger than min_size
124126
"""
125-
_log_api_usage_once("ops", "remove_small_boxes")
127+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
128+
_log_api_usage_once(remove_small_boxes)
126129
ws, hs = boxes[:, 2] - boxes[:, 0], boxes[:, 3] - boxes[:, 1]
127130
keep = (ws >= min_size) & (hs >= min_size)
128131
keep = torch.where(keep)[0]
@@ -141,7 +144,8 @@ def clip_boxes_to_image(boxes: Tensor, size: Tuple[int, int]) -> Tensor:
141144
Returns:
142145
Tensor[N, 4]: clipped boxes
143146
"""
144-
_log_api_usage_once("ops", "clip_boxes_to_image")
147+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
148+
_log_api_usage_once(clip_boxes_to_image)
145149
dim = boxes.dim()
146150
boxes_x = boxes[..., 0::2]
147151
boxes_y = boxes[..., 1::2]
@@ -181,8 +185,8 @@ def box_convert(boxes: Tensor, in_fmt: str, out_fmt: str) -> Tensor:
181185
Returns:
182186
Tensor[N, 4]: Boxes into converted format.
183187
"""
184-
185-
_log_api_usage_once("ops", "box_convert")
188+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
189+
_log_api_usage_once(box_convert)
186190
allowed_fmts = ("xyxy", "xywh", "cxcywh")
187191
if in_fmt not in allowed_fmts or out_fmt not in allowed_fmts:
188192
raise ValueError("Unsupported Bounding Box Conversions for given in_fmt and out_fmt")
@@ -232,7 +236,8 @@ def box_area(boxes: Tensor) -> Tensor:
232236
Returns:
233237
Tensor[N]: the area for each box
234238
"""
235-
_log_api_usage_once("ops", "box_area")
239+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
240+
_log_api_usage_once(box_area)
236241
boxes = _upcast(boxes)
237242
return (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1])
238243

@@ -268,7 +273,8 @@ def box_iou(boxes1: Tensor, boxes2: Tensor) -> Tensor:
268273
Returns:
269274
Tensor[N, M]: the NxM matrix containing the pairwise IoU values for every element in boxes1 and boxes2
270275
"""
271-
_log_api_usage_once("ops", "box_iou")
276+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
277+
_log_api_usage_once(box_iou)
272278
inter, union = _box_inter_union(boxes1, boxes2)
273279
iou = inter / union
274280
return iou
@@ -290,8 +296,8 @@ def generalized_box_iou(boxes1: Tensor, boxes2: Tensor) -> Tensor:
290296
Tensor[N, M]: the NxM matrix containing the pairwise generalized IoU values
291297
for every element in boxes1 and boxes2
292298
"""
293-
294-
_log_api_usage_once("ops", "generalized_box_iou")
299+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
300+
_log_api_usage_once(generalized_box_iou)
295301
# degenerate boxes gives inf / nan results
296302
# so do an early check
297303
assert (boxes1[:, 2:] >= boxes1[:, :2]).all()
@@ -323,7 +329,8 @@ def masks_to_boxes(masks: torch.Tensor) -> torch.Tensor:
323329
Returns:
324330
Tensor[N, 4]: bounding boxes
325331
"""
326-
_log_api_usage_once("ops", "masks_to_boxes")
332+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
333+
_log_api_usage_once(masks_to_boxes)
327334
if masks.numel() == 0:
328335
return torch.zeros((0, 4), device=masks.device, dtype=torch.float)
329336

torchvision/ops/deform_conv.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def deform_conv2d(
6060
>>> # returns
6161
>>> torch.Size([4, 5, 8, 8])
6262
"""
63-
64-
_log_api_usage_once("ops", "deform_conv2d")
63+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
64+
_log_api_usage_once(deform_conv2d)
6565
_assert_has_ops()
6666
out_channels = weight.shape[0]
6767

@@ -124,6 +124,7 @@ def __init__(
124124
bias: bool = True,
125125
):
126126
super().__init__()
127+
_log_api_usage_once(self)
127128

128129
if in_channels % groups != 0:
129130
raise ValueError("in_channels must be divisible by groups")

torchvision/ops/feature_pyramid_network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
extra_blocks: Optional[ExtraFPNBlock] = None,
7878
):
7979
super().__init__()
80-
_log_api_usage_once("ops", self.__class__.__name__)
80+
_log_api_usage_once(self)
8181
self.inner_blocks = nn.ModuleList()
8282
self.layer_blocks = nn.ModuleList()
8383
for in_channels in in_channels_list:

torchvision/ops/focal_loss.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def sigmoid_focal_loss(
3232
Returns:
3333
Loss tensor with the reduction option applied.
3434
"""
35-
_log_api_usage_once("ops", "sigmoid_focal_loss")
35+
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
36+
_log_api_usage_once(sigmoid_focal_loss)
3637
p = torch.sigmoid(inputs)
3738
ce_loss = F.binary_cross_entropy_with_logits(inputs, targets, reduction="none")
3839
p_t = p * targets + (1 - p) * (1 - targets)

0 commit comments

Comments
 (0)