mindspore.nn.MulQuant

class mindspore.nn.MulQuant(ema_decay=0.999, quant_config=quant_config_default, quant_dtype=QuantDtype.INT8)[source]

Adds fake quantized operation after Mul operation.

This part is a more detailed overview of Mul operation. For more detials about Quantilization, please refer to mindspore.nn.FakeQuantWithMinMaxObserver.

Parameters
  • ema_decay (float) – Exponential Moving Average algorithm parameter. Default: 0.999.

  • quant_config (QuantConfig) – Configures the oberser types and quant settings of weight and activation. Can be generated by compression.quant.create_quant_config method. Default: both set to default FakeQuantWithMinMaxObserver.

  • quant_dtype (QuantDtype) – Specifies the FakeQuant datatype. Default: QuantDtype.INT8.

Inputs:
  • input_x1 (Tensor) - The first tensor of MulQuant.

  • input_x2 (Tensor) - The second tensor of MulQuant.

Outputs:

Tensor, with the same type and shape as the input_x1.

Raises

TypeError – If ema_decay is not a float.

Supported Platforms:

Ascend GPU

Examples

>>> qconfig = compression.quant.create_quant_config()
>>> mul_quant = nn.MulQuant(quant_config=qconfig)
>>> input_x1 = Tensor(np.array([[1, 2, 1], [-2, 0, -1]]), mindspore.float32)
>>> input_x2 = Tensor(np.ones((2, 3)) * 2, mindspore.float32)
>>> output = mul_quant(input_x1, input_x2)
>>> print(output)
[[ 1.9764705  4.0000005  1.9764705]
 [-4.         0.        -1.9764705]]