Quantifiable Layers and Constraints

This section lists the quantifiable layers available in different frameworks and their constraints.

  • If the input data type or weight data type of the network model is float16 or mixed precision of float32 and float16, the quantization of the following operators is disabled:

    AvgPool, Pooling, AvgPoolV2, MaxPool, MaxPoolV3, Add, Eltwise, and BatchMatMulV2 (both inputs are variable tensors).

  • The Caffe framework does not evolve in the following product forms, and its functions are not guaranteed:

    Atlas A2 products

    Atlas A3 products

  • Layers that support uniform quantization and their constraints (Caffe)

    Supported Layer Type

    Constraints

    Ascend IR–defined Layer

    InnerProduct

    transpose = false; axis = 1

    FullyConnection

    Convolution

    filter is a 4D tensor.

    Conv2D

    Deconvolution

    dilation is set to 1, and filter is a 4D tensor.

    Deconvolution

    Pooling

    • If mode is set to 1 for full quantization (weight + tensor), and global_pooling is set to false, the shift-N operation is not supported.
    • If mode is set to 0, only tensor quantization is performed.

    Pooling

    Eltwise

    Only tensor quantization is performed and operation must be set to 1.

    Eltwise

  • Layers that support uniform quantization and their constraints (TensorFlow)

    Supported Layer Type

    Constraints

    Ascend IR–defined Layer

    MatMul

    • transpose_a, transpose_b, adjoint_a, and adjoint_b must be set to False.
    • The input sources of weights must not contain dynamically variable nodes such as placeholders.

    MatMulV2

    Conv2D

    The input sources of weights must not contain dynamically variable nodes such as placeholders.

    Conv2D

    DepthwiseConv2dNative

    The input sources of weights must not contain dynamically variable nodes such as placeholders.

    DepthwiseConv2D

    Conv2DBackpropInput

    dilation must be 1, and the input sources of weights must not contain dynamically variable nodes such as placeholders.

    Conv2DBackpropInput

    BatchMatMulV2

    • adj_x=False
    • When the second input is a constant, only two dimensions are supported.
    • When both inputs are variable tensors, only INT8 symmetric quantization is supported.

      When both inputs are variable tensors, performance gains can be achieved only for the products listed below. The accuracy degrades after quantization on other products.

      Atlas 200I/500 A2 inference products

      Atlas A2 products

      Atlas A3 products

    BatchMatMulV2

    AvgPool

    The shift-N operation is not supported.

    AvgPool

    Conv3D

    dilation_d = 1

    Conv3D

    MaxPool

    Only tensor quantization is performed.

    MaxPool, MaxPoolV3

    Add

    Only tensor quantization is performed, and only single-input quantization is supported.

    Add

  • Layers that support uniform quantization and their constraints (ONNX)

    Supported Layer Type

    Constraints

    Ascend IR–defined Layer

    Conv

    • dilation_d must be 1 when the filter is 5D.
    • The input sources of weights must not contain dynamically variable nodes such as placeholders.

    Conv2D, Conv3D

    Gemm

    • transpose_a = false
    • The input sources of weights must not contain dynamically variable nodes such as placeholders.

    MatMulV2

    ConvTranspose

    • dilation is set to 1, and filter is a 4D tensor.
    • The input sources of weights must not contain dynamically variable nodes such as placeholders.

    Conv2DTranspose

    MatMul

    • When the second input is a constant, only two dimensions are supported.
    • When both inputs are variable tensors, only INT8 symmetric quantization is supported.

      Performance gains can be achieved only for the products listed below when both inputs are variable tensors; the accuracy degrades after quantization on other products.

      Atlas 200I/500 A2 inference products

      Atlas A2 products

      Atlas A3 products

    • The input sources of weights must not contain dynamically variable nodes such as placeholders.

    BatchMatMulV2

    AveragePool

    When global_pooling is set to false, the shift-N operation is not supported.

    AvgPoolV2

    MaxPool

    Only tensor quantization is performed.

    MaxPool, MaxPoolV3

    Add

    Only tensor quantization is performed, and only single-input quantization is supported.

    Add

Weight-only quantization is supported only by the following product types:

Atlas inference products

Atlas A2 products

Table 1 Layers that support weight-only quantization and their constraints

Ascend IR–defined Layer

Weight-Only Quantization:

channel_wise = true in Weight ARQ

Weight-Only Quantization:

asymmetric in Weight ARQ (true/false)

Weight and Activation Quantization:

channel_wise = true in Weight ARQ

Weight and Activation Quantization:

asymmetric = true in Weight ARQ

Constraints

MatMulV2

√

true

×

×

The sources of the second input must not contain dynamically variable nodes such as placeholders.

BatchMatMulV2

√

true

×

×

The sources of the second input must not contain dynamically variable nodes such as placeholders.

FFN

√

true and false

×

×

  • The expert_tokens input of the FFN operator is not empty.
  • The two weights of the FFN operator are Float16 constants.
  • The antiquant_scale1, antiquant_scale2, antiquant_offset1, and antiquant_offset2 inputs of the FFN operator are empty.
  • Weight sharing is not supported.
  • FFN operator quantization is supported only by the Atlas A2 products.

Notes:

  • √ indicates supported; × indicates that an exception occurs during quantization in this scenario.
  • channel_wise = true in Weight ARQ indicates that each channel is quantized independently with distinct quantization factors.
  • asymmetric in Weight ARQ
    • true: Asymmetric quantization is applied for weight-only quantization.
    • false: Symmetric quantization is applied for weight-only quantization.
    • true and false indicate that symmetric quantization and asymmetric quantization are supported for weight-only quantization.