"...text-generation-inference.git" did not exist on "ac8c0f6fe4c0c061e0f858242ee61dfa090c32a6"
Unverified Commit a6336f7a authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Add Docs for QuantizedGoogleNet (#5975)

* Add Docs for QuantizedGoogleNet

* ufmt

* Use explicit _QuantizedWeights or _Weights suffix
parent 651b97e2
......@@ -315,7 +315,7 @@ def inject_weight_metadata(app, what, name, obj, options, lines):
used within the autoclass directive.
"""
if obj.__name__.endswith("_Weights"):
if obj.__name__.endswith(("_Weights", "_QuantizedWeights")):
lines[:] = [
"The model builder above accepts the following values as the ``weights`` parameter.",
f"``{obj.__name__}.DEFAULT`` is equivalent to ``{obj.DEFAULT}``.",
......@@ -349,7 +349,8 @@ def inject_weight_metadata(app, what, name, obj, options, lines):
def generate_weights_table(module, table_name, metrics, include_patterns=None, exclude_patterns=None):
weight_enums = [getattr(module, name) for name in dir(module) if name.endswith("_Weights")]
weights_endswith = "_QuantizedWeights" if module.__name__.split(".")[-1] == "quantization" else "_Weights"
weight_enums = [getattr(module, name) for name in dir(module) if name.endswith(weights_endswith)]
weights = [w for weight_enum in weight_enums for w in weight_enum]
if include_patterns is not None:
......@@ -382,6 +383,9 @@ def generate_weights_table(module, table_name, metrics, include_patterns=None, e
generate_weights_table(module=M, table_name="classification", metrics=[("acc@1", "Acc@1"), ("acc@5", "Acc@5")])
generate_weights_table(
module=M.quantization, table_name="classification_quant", metrics=[("acc@1", "Acc@1"), ("acc@5", "Acc@5")]
)
generate_weights_table(
module=M.detection, table_name="detection", metrics=[("box_map", "Box MAP")], exclude_patterns=["Mask", "Keypoint"]
)
......
Quantized GoogLeNet
===================
.. currentmodule:: torchvision.models.quantization
The Quantized GoogleNet model is based on the `Going Deeper with Convolutions <https://arxiv.org/abs/1409.4842>`__
paper.
Model builders
--------------
The following model builders can be used to instanciate a quantized GoogLeNet
model, with or without pre-trained weights. All the model builders internally
rely on the ``torchvision.models.quantization.googlenet.QuantizableGoogLeNet``
base class. Please refer to the `source code
<https://github.com/pytorch/vision/blob/main/torchvision/models/quantization/googlenet.py>`_
for more details about this class.
.. autosummary::
:toctree: generated/
:template: function.rst
googlenet
......@@ -65,6 +65,27 @@ Accuracies are reported on ImageNet
.. include:: generated/classification_table.rst
Quantized models
----------------
.. currentmodule:: torchvision.models.quantization
The following quantized classification models are available, with or without
pre-trained weights:
.. toctree::
:maxdepth: 1
models/googlenet_quant
Table of all available quantized classification weights
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Accuracies are reported on ImageNet
.. include:: generated/classification_quant_table.rst
Semantic Segmentation
=====================
......
......@@ -295,8 +295,9 @@ class GoogLeNet_Weights(WeightsEnum):
@handle_legacy_interface(weights=("pretrained", GoogLeNet_Weights.IMAGENET1K_V1))
def googlenet(*, weights: Optional[GoogLeNet_Weights] = None, progress: bool = True, **kwargs: Any) -> GoogLeNet:
r"""GoogLeNet (Inception v1) model architecture from
"""GoogLeNet (Inception v1) model architecture from
`Going Deeper with Convolutions <http://arxiv.org/abs/1409.4842>`_.
The required minimum input size of the model is 15x15.
Args:
......
......@@ -141,18 +141,34 @@ def googlenet(
quantize: bool = False,
**kwargs: Any,
) -> QuantizableGoogLeNet:
r"""GoogLeNet (Inception v1) model architecture from
`"Going Deeper with Convolutions" <http://arxiv.org/abs/1409.4842>`_.
"""GoogLeNet (Inception v1) model architecture from `Going Deeper with Convolutions <http://arxiv.org/abs/1409.4842>`__.
Note that quantize = True returns a quantized model with 8 bit
Note that ``quantize = True`` returns a quantized model with 8 bit
weights. Quantized models only support inference and run on CPUs.
GPU inference is not yet supported
The required minimum input size of the model is 15x15.
Args:
weights (GoogLeNet_QuantizedWeights or GoogLeNet_Weights, optional): The pretrained
weights for the model
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
weights (:class:`~torchvision.models.quantization.GoogLeNet_QuantizedWeights` or :class:`~torchvision.models.GoogLeNet_Weights`, optional): The
pretrained weights for the model. See
:class:`~torchvision.models.quantization.GoogLeNet_QuantizedWeights` below for
more details, and possible values. By default, no pre-trained
weights are used.
progress (bool, optional): If True, displays a progress bar of the
download to stderr. Default is True.
quantize (bool, optional): If True, return a quantized version of the model. Default is False.
**kwargs: parameters passed to the ``torchvision.models.quantization.QuantizableGoogLeNet``
base class. Please refer to the `source code
<https://github.com/pytorch/vision/blob/main/torchvision/models/quantization.googlenet.py>`_
for more details about this class.
.. autoclass:: torchvision.models.quantization.GoogLeNet_QuantizedWeights
:members:
.. autoclass:: torchvision.models.GoogLeNet_Weights
:members:
:noindex:
"""
weights = (GoogLeNet_QuantizedWeights if quantize else GoogLeNet_Weights).verify(weights)
......
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