Skip to content

Commit 3414322

Browse files
authored
Handle empty weights in doc generation (#6006)
1 parent ddb342d commit 3414322

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

docs/source/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ def inject_weight_metadata(app, what, name, obj, options, lines):
316316
"""
317317

318318
if obj.__name__.endswith(("_Weights", "_QuantizedWeights")):
319+
320+
if len(obj) == 0:
321+
lines[:] = ["There are no available pre-trained weights."]
322+
return
323+
319324
lines[:] = [
320325
"The model builder above accepts the following values as the ``weights`` parameter.",
321326
f"``{obj.__name__}.DEFAULT`` is equivalent to ``{obj.DEFAULT}``.",

torchvision/models/mnasnet.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ def mnasnet0_75(*, weights: Optional[MNASNet0_75_Weights] = None, progress: bool
316316
<https://github.com/pytorch/vision/blob/main/torchvision/models/mnasnet.py>`_
317317
for more details about this class.
318318
319+
.. autoclass:: torchvision.models.MNASNet0_75_Weights
320+
:members:
319321
"""
320322
weights = MNASNet0_75_Weights.verify(weights)
321323

@@ -366,6 +368,8 @@ def mnasnet1_3(*, weights: Optional[MNASNet1_3_Weights] = None, progress: bool =
366368
<https://github.com/pytorch/vision/blob/main/torchvision/models/mnasnet.py>`_
367369
for more details about this class.
368370
371+
.. autoclass:: torchvision.models.MNASNet1_3_Weights
372+
:members:
369373
"""
370374
weights = MNASNet1_3_Weights.verify(weights)
371375

0 commit comments

Comments
 (0)