From f76ee4de31db205723a7e45ee06774bed8d36017 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Thu, 18 Jan 2024 16:41:38 +0800 Subject: [PATCH 1/2] fix docstring --- python/paddle/base/framework.py | 2 +- python/paddle/nn/functional/vision.py | 2 +- python/paddle/nn/quant/stub.py | 8 ++++---- python/paddle/quantization/factory.py | 2 +- python/paddle/quantization/ptq.py | 4 ++-- python/paddle/quantization/qat.py | 6 +++--- python/paddle/quantization/quantize.py | 8 ++++---- python/paddle/quantization/wrapper.py | 6 +++--- python/paddle/text/datasets/wmt14.py | 6 +++--- python/paddle/text/datasets/wmt16.py | 6 +++--- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/python/paddle/base/framework.py b/python/paddle/base/framework.py index f8d689c1e578e0..7cef1cde9f17ce 100644 --- a/python/paddle/base/framework.py +++ b/python/paddle/base/framework.py @@ -6963,7 +6963,7 @@ def block(self, index): Get the :code:`index` :ref:`api_guide_Block_en` of this Program Args: - index (int) - The index of :ref:`api_guide_Block_en` to get + index (int): The index of :ref:`api_guide_Block_en` to get Returns: :ref:`api_guide_Block_en`: The :code:`index` block diff --git a/python/paddle/nn/functional/vision.py b/python/paddle/nn/functional/vision.py index d41e5cef8729b6..508fd1a7c40baf 100644 --- a/python/paddle/nn/functional/vision.py +++ b/python/paddle/nn/functional/vision.py @@ -36,7 +36,7 @@ def affine_grid(theta, out_shape, align_corners=True, name=None): output feature map. Args: - theta (Tensor) - A tensor with shape [N, 2, 3] or [N, 3, 4]. It contains a batch of affine transform parameters. + theta (Tensor): A tensor with shape [N, 2, 3] or [N, 3, 4]. It contains a batch of affine transform parameters. The data type can be float32 or float64. out_shape (Tensor | list | tuple): Type can be a 1-D Tensor, list, or tuple. It is used to represent the shape of the output in an affine transformation, in the format ``[N, C, H, W]`` or ``[N, C, D, H, W]``. When the format is ``[N, C, H, W]``, it represents the batch size, number of channels, height and width. When the format is ``[N, C, D, H, W]``, it represents the batch size, number of channels, depth, height and width. diff --git a/python/paddle/nn/quant/stub.py b/python/paddle/nn/quant/stub.py index 314319caa707dc..96c08c534a4216 100644 --- a/python/paddle/nn/quant/stub.py +++ b/python/paddle/nn/quant/stub.py @@ -26,8 +26,8 @@ class Stub(Layer): stub will observe or quantize the inputs of the functional API. Args: - observer(QuanterFactory) - The configured information of the observer to be inserted. - It will use a global configuration to create the observers if the 'observer' is none. + observer(QuanterFactory): The configured information of the observer to be inserted. + It will use a global configuration to create the observers if the 'observer' is none. Examples: .. code-block:: python @@ -81,9 +81,9 @@ class QuanterStub(Layer): The user should not use this class directly. Args: - layer(paddle.nn.Layer) - The stub layer with an observer configure factory. If the observer + layer(paddle.nn.Layer): The stub layer with an observer configure factory. If the observer of the stub layer is none, it will use 'q_config' to create an observer instance. - q_config(QuantConfig) - The quantization configuration for the current stub layer. + q_config(QuantConfig): The quantization configuration for the current stub layer. """ def __init__(self, layer: Stub, q_config): diff --git a/python/paddle/quantization/factory.py b/python/paddle/quantization/factory.py index eb8916460975c8..c1635a03aaa712 100644 --- a/python/paddle/quantization/factory.py +++ b/python/paddle/quantization/factory.py @@ -78,7 +78,7 @@ def quanter(class_name): Annotation to declare a factory class for quanter. Args: - class_name (str) - The name of factory class to be declared. + class_name (str): The name of factory class to be declared. Examples: .. code-block:: python diff --git a/python/paddle/quantization/ptq.py b/python/paddle/quantization/ptq.py index cdd1b9403e0f7d..6a5562abb94076 100644 --- a/python/paddle/quantization/ptq.py +++ b/python/paddle/quantization/ptq.py @@ -47,8 +47,8 @@ def quantize(self, model: Layer, inplace=False): quantization parameters. Args: - model(Layer) - The model to be quantized. - inplace(bool) - Whether to modify the model in-place. + model(Layer): The model to be quantized. + inplace(bool): Whether to modify the model in-place. Return: The prepared model for post-training quantization. diff --git a/python/paddle/quantization/qat.py b/python/paddle/quantization/qat.py index b851e473b6003f..e762400c316f7f 100644 --- a/python/paddle/quantization/qat.py +++ b/python/paddle/quantization/qat.py @@ -24,7 +24,7 @@ class QAT(Quantization): r""" Tools used to prepare model for quantization-aware training. Args: - config(QuantConfig) - Quantization configuration + config(QuantConfig): Quantization configuration Examples: .. code-block:: python @@ -47,8 +47,8 @@ def quantize(self, model: Layer, inplace=False): And it will insert fake quanters into the model to simulate the quantization. Args: - model(Layer) - The model to be quantized. - inplace(bool) - Whether to modify the model in-place. + model(Layer): The model to be quantized. + inplace(bool): Whether to modify the model in-place. Return: The prepared model for quantization-aware training. diff --git a/python/paddle/quantization/quantize.py b/python/paddle/quantization/quantize.py index b7887ffc46e1c4..9bd0940d1c5b2b 100644 --- a/python/paddle/quantization/quantize.py +++ b/python/paddle/quantization/quantize.py @@ -29,7 +29,7 @@ class Quantization(metaclass=abc.ABCMeta): r""" Abstract class used to prepares a copy of the model for quantization calibration or quantization-aware training. Args: - config(QuantConfig) - Quantization configuration + config(QuantConfig): Quantization configuration """ def __init__(self, config: QuantConfig): @@ -44,9 +44,9 @@ def convert(self, model: Layer, inplace=False, remain_weight=False): r"""Convert the quantization model to ONNX style. And the converted model can be saved as inference model by calling paddle.jit.save. Args: - model(Layer) - The quantized model to be converted. - inplace(bool, optional) - Whether to modify the model in-place, default is False. - remain_weight(bool, optional) - Whether to remain weights in floats, default is False. + model(Layer): The quantized model to be converted. + inplace(bool, optional): Whether to modify the model in-place, default is False. + remain_weight(bool, optional): Whether to remain weights in floats, default is False. Return: The converted model diff --git a/python/paddle/quantization/wrapper.py b/python/paddle/quantization/wrapper.py index cef847a5a1b051..3c722ab95d544f 100644 --- a/python/paddle/quantization/wrapper.py +++ b/python/paddle/quantization/wrapper.py @@ -22,9 +22,9 @@ class ObserveWrapper(Layer): Put an observer layer and an observed layer into a wrapping layer. It is used to insert layers into the model for QAT or PTQ. Args: - observer(BaseQuanter) - Observer layer - observed(Layer) - Observed layer - observe_input(bool) - If it is true the observer layer will be called before observed layer. + observer(BaseQuanter): Observer layer + observed(Layer): Observed layer + observe_input(bool): If it is true the observer layer will be called before observed layer. If it is false the observed layer will be called before observer layer. Default: True. """ diff --git a/python/paddle/text/datasets/wmt14.py b/python/paddle/text/datasets/wmt14.py index a2d7c9ebe58712..1472369050b692 100644 --- a/python/paddle/text/datasets/wmt14.py +++ b/python/paddle/text/datasets/wmt14.py @@ -54,9 +54,9 @@ class WMT14(Dataset): Returns: Dataset: Instance of WMT14 dataset - - src_ids (np.array) - The sequence of token ids of source language. - - trg_ids (np.array) - The sequence of token ids of target language. - - trg_ids_next (np.array) - The next sequence of token ids of target language. + - src_ids (np.array): The sequence of token ids of source language. + - trg_ids (np.array): The sequence of token ids of target language. + - trg_ids_next (np.array): The next sequence of token ids of target language. Examples: .. code-block:: python diff --git a/python/paddle/text/datasets/wmt16.py b/python/paddle/text/datasets/wmt16.py index 79bd13c9538e51..b22e1ed59afc17 100644 --- a/python/paddle/text/datasets/wmt16.py +++ b/python/paddle/text/datasets/wmt16.py @@ -69,9 +69,9 @@ class WMT16(Dataset): Returns: Dataset: Instance of WMT16 dataset. The instance of dataset has 3 fields: - - src_ids (np.array) - The sequence of token ids of source language. - - trg_ids (np.array) - The sequence of token ids of target language. - - trg_ids_next (np.array) - The next sequence of token ids of target language. + - src_ids (np.array): The sequence of token ids of source language. + - trg_ids (np.array): The sequence of token ids of target language. + - trg_ids_next (np.array): The next sequence of token ids of target language. Examples: From e736d0235f9114c9f58e4e3f315ed881087d1a95 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Fri, 19 Jan 2024 14:34:19 +0800 Subject: [PATCH 2/2] update --- python/paddle/text/datasets/wmt14.py | 6 +++--- python/paddle/text/datasets/wmt16.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/paddle/text/datasets/wmt14.py b/python/paddle/text/datasets/wmt14.py index 1472369050b692..a2d7c9ebe58712 100644 --- a/python/paddle/text/datasets/wmt14.py +++ b/python/paddle/text/datasets/wmt14.py @@ -54,9 +54,9 @@ class WMT14(Dataset): Returns: Dataset: Instance of WMT14 dataset - - src_ids (np.array): The sequence of token ids of source language. - - trg_ids (np.array): The sequence of token ids of target language. - - trg_ids_next (np.array): The next sequence of token ids of target language. + - src_ids (np.array) - The sequence of token ids of source language. + - trg_ids (np.array) - The sequence of token ids of target language. + - trg_ids_next (np.array) - The next sequence of token ids of target language. Examples: .. code-block:: python diff --git a/python/paddle/text/datasets/wmt16.py b/python/paddle/text/datasets/wmt16.py index b22e1ed59afc17..79bd13c9538e51 100644 --- a/python/paddle/text/datasets/wmt16.py +++ b/python/paddle/text/datasets/wmt16.py @@ -69,9 +69,9 @@ class WMT16(Dataset): Returns: Dataset: Instance of WMT16 dataset. The instance of dataset has 3 fields: - - src_ids (np.array): The sequence of token ids of source language. - - trg_ids (np.array): The sequence of token ids of target language. - - trg_ids_next (np.array): The next sequence of token ids of target language. + - src_ids (np.array) - The sequence of token ids of source language. + - trg_ids (np.array) - The sequence of token ids of target language. + - trg_ids_next (np.array) - The next sequence of token ids of target language. Examples: