def quantize(self, model):
    "\n        According to weights' and activations' quantization types,\n        the model will be added some fake quant ops, such as\n        fake_quantize_dequantize_moving_average_abs_max,\n        fake_quantize_dequantize_abs_max and so on. At the same time,\n        the out_scale value of outputs would be calculated.\n\n        Args:\n            model(paddle.nn.Layer): the model to be quantized.\n        Returns:\n            None\n\n        Examples:\n        .. code-block:: python\n\n            import paddle\n            from paddle.fluid.contrib.slim.quantization                 import ImperativeQuantAware\n\n            class ImperativeModel(paddle.nn.Layer):\n                def __init__(self):\n                    super(ImperativeModel, self).__init__()\n                    # self.linear_0 would skip the quantization.\n                    self.linear_0 = paddle.nn.Linear(784, 400)\n                    self.linear_0.skip_quant = True\n\n                    # self.linear_1 would not skip the quantization.\n                    self.linear_1 = paddle.nn.Linear(400, 10)\n                    self.linear_1.skip_quant = False\n\n                def forward(self, inputs):\n                    x = self.linear_0(inputs)\n                    x = self.linear_1(inputs)\n                    return x\n\n            model = ImperativeModel()\n            imperative_qat = ImperativeQuantAware(\n                weight_quantize_type='abs_max',\n                activation_quantize_type='moving_average_abs_max')\n\n            # Add the fake quant logical.\n            # The original model will be rewrite.\n            #\n            # There is only one Layer(self.linear1) would be added the\n            # fake quant logical.\n            imperative_qat.quantize(model)\n        "
    assert isinstance(model, dygraph.Layer), 'The model must be the instance of dygraph.Layer.'
    self._quantize_inputs.apply(model)
    self._quantize_outputs.apply(model)
According to weights' and activations' quantization types,
the model will be added some fake quant ops, such as
fake_quantize_dequantize_moving_average_abs_max,
fake_quantize_dequantize_abs_max and so on. At the same time,
the out_scale value of outputs would be calculated.

Args:
    model(paddle.nn.Layer): the model to be quantized.
Returns:
    None

Examples:
.. code-block:: python

    import paddle
    from paddle.fluid.contrib.slim.quantization                 import ImperativeQuantAware

    class ImperativeModel(paddle.nn.Layer):
        def __init__(self):
            super(ImperativeModel, self).__init__()
            # self.linear_0 would skip the quantization.
            self.linear_0 = paddle.nn.Linear(784, 400)
            self.linear_0.skip_quant = True

            # self.linear_1 would not skip the quantization.
            self.linear_1 = paddle.nn.Linear(400, 10)
            self.linear_1.skip_quant = False

        def forward(self, inputs):
            x = self.linear_0(inputs)
            x = self.linear_1(inputs)
            return x

    model = ImperativeModel()
    imperative_qat = ImperativeQuantAware(
        weight_quantize_type='abs_max',
        activation_quantize_type='moving_average_abs_max')

    # Add the fake quant logical.
    # The original model will be rewrite.
    #
    # There is only one Layer(self.linear1) would be added the
    # fake quant logical.
    imperative_qat.quantize(model)
def quantize(self, model):
    "\n        According to weights' and activations' quantization types,\n        the model will be added some fake quant ops, such as\n        fake_quantize_dequantize_moving_average_abs_max,\n        fake_quantize_dequantize_abs_max and so on. At the same time,\n        the out_scale value of outputs would be calculated.\n\n        Args:\n            model(paddle.nn.Layer): the model to be quantized.\n        Returns:\n            None\n\n        Examples:\n        .. code-block:: python\n\n            import paddle\n            from paddle.fluid.contrib.slim.quantization                 import ImperativeQuantAware\n\n            class ImperativeModel(paddle.nn.Layer):\n                def __init__(self):\n                    super(ImperativeModel, self).__init__()\n                    # self.linear_0 would skip the quantization.\n                    self.linear_0 = paddle.nn.Linear(784, 400)\n                    self.linear_0.skip_quant = True\n\n                    # self.linear_1 would not skip the quantization.\n                    self.linear_1 = paddle.nn.Linear(400, 10)\n                    self.linear_1.skip_quant = False\n\n                def forward(self, inputs):\n                    x = self.linear_0(inputs)\n                    x = self.linear_1(inputs)\n                    return x\n\n            model = ImperativeModel()\n            imperative_qat = ImperativeQuantAware(\n                weight_quantize_type='abs_max',\n                activation_quantize_type='moving_average_abs_max')\n\n            # Add the fake quant logical.\n            # The original model will be rewrite.\n            #\n            # There is only one Layer(self.linear1) would be added the\n            # fake quant logical.\n            imperative_qat.quantize(model)\n        "
    assert isinstance(model, dygraph.Layer), 'The model must be the instance of dygraph.Layer.'
    self._quantize_inputs.apply(model)
    self._quantize_outputs.apply(model)