Skip to content

Commit 4a004a9

Browse files
committed
use decorator to log API usage
1 parent 999ef25 commit 4a004a9

33 files changed

+57
-54
lines changed

torchvision/datasets/vision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ class VisionDataset(data.Dataset):
2828

2929
_repr_indent = 4
3030

31+
@_log_api_usage_once
3132
def __init__(
3233
self,
3334
root: str,
3435
transforms: Optional[Callable] = None,
3536
transform: Optional[Callable] = None,
3637
target_transform: Optional[Callable] = None,
3738
) -> None:
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
@@ -16,9 +16,9 @@
1616

1717

1818
class AlexNet(nn.Module):
19+
@_log_api_usage_once
1920
def __init__(self, num_classes: int = 1000, dropout: float = 0.5) -> None:
2021
super().__init__()
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class DenseNet(nn.Module):
151151
but slower. Default: *False*. See `"paper" <https://arxiv.org/pdf/1707.06990.pdf>`_.
152152
"""
153153

154+
@_log_api_usage_once
154155
def __init__(
155156
self,
156157
growth_rate: int = 32,
@@ -161,9 +162,7 @@ def __init__(
161162
num_classes: int = 1000,
162163
memory_efficient: bool = False,
163164
) -> None:
164-
165165
super().__init__()
166-
_log_api_usage_once(self)
167166

168167
# First convolution
169168
self.features = nn.Sequential(

torchvision/models/detection/generalized_rcnn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class GeneralizedRCNN(nn.Module):
2525
the model
2626
"""
2727

28+
@_log_api_usage_once
2829
def __init__(self, backbone: nn.Module, rpn: nn.Module, roi_heads: nn.Module, transform: nn.Module) -> None:
2930
super().__init__()
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
@@ -316,6 +316,7 @@ class RetinaNet(nn.Module):
316316
"proposal_matcher": det_utils.Matcher,
317317
}
318318

319+
@_log_api_usage_once
319320
def __init__(
320321
self,
321322
backbone,
@@ -337,7 +338,6 @@ def __init__(
337338
topk_candidates=1000,
338339
):
339340
super().__init__()
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
@@ -165,6 +165,7 @@ class SSD(nn.Module):
165165
"proposal_matcher": det_utils.Matcher,
166166
}
167167

168+
@_log_api_usage_once
168169
def __init__(
169170
self,
170171
backbone: nn.Module,
@@ -182,7 +183,6 @@ def __init__(
182183
positive_fraction: float = 0.25,
183184
):
184185
super().__init__()
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
@@ -111,6 +111,7 @@ def __init__(self, in_channels: List[int], num_anchors: List[int], norm_layer: C
111111

112112

113113
class SSDLiteFeatureExtractorMobileNet(nn.Module):
114+
@_log_api_usage_once
114115
def __init__(
115116
self,
116117
backbone: nn.Module,
@@ -120,7 +121,6 @@ def __init__(
120121
min_depth: int = 16,
121122
):
122123
super().__init__()
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
@@ -148,6 +148,7 @@ def forward(self, input: Tensor) -> Tensor:
148148

149149

150150
class EfficientNet(nn.Module):
151+
@_log_api_usage_once
151152
def __init__(
152153
self,
153154
inverted_residual_setting: List[MBConvConfig],
@@ -170,7 +171,6 @@ def __init__(
170171
norm_layer (Optional[Callable[..., nn.Module]]): Module specifying the normalization layer to use
171172
"""
172173
super().__init__()
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
@@ -28,6 +28,7 @@
2828
class GoogLeNet(nn.Module):
2929
__constants__ = ["aux_logits", "transform_input"]
3030

31+
@_log_api_usage_once
3132
def __init__(
3233
self,
3334
num_classes: int = 1000,
@@ -39,7 +40,6 @@ def __init__(
3940
dropout_aux: float = 0.7,
4041
) -> None:
4142
super().__init__()
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
@@ -27,6 +27,7 @@
2727

2828

2929
class Inception3(nn.Module):
30+
@_log_api_usage_once
3031
def __init__(
3132
self,
3233
num_classes: int = 1000,
@@ -37,7 +38,6 @@ def __init__(
3738
dropout: float = 0.5,
3839
) -> None:
3940
super().__init__()
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:

0 commit comments

Comments
 (0)