API description: performs MX quantization with the destination data type being FLOAT4. Only the last axis is quantized. All the previous axes are fused together. The input is divided into multiple data blocks based on the given level0BlockSize, and level-1 quantization is performed on each data block to output the quantization scale level0ScaleOut. Then, the level-1 quantization result is used as the new input, and is divided into multiple data blocks based on the given level1BlockSize. Level-2 quantization is performed on each data block to output the quantization scale level1ScaleOut. The data type is converted based on the round_mode to obtain the quantization result yOut. For details, see the figure (see../figures/DynamicDualLevelMxQuant.png).
Formulas:
- The input x is grouped into = level0BlockSize groups along the last axis. A group of elements is dynamically quantized into , where = level0BlockSize. Then, the temp is grouped into = level1BlockSize groups along the last axis. A group of elements is dynamically quantized into , where = level1BlockSize.
The quantized forms the output yOut based on the corresponding positions of . The level0Scale forms the output level0ScaleOut based on the corresponding groups of the last axis. The level1Scale forms the output level1ScaleOut based on the corresponding groups of the last axis.
max_i indicates the maximum value in the ith group.
emax: exponent bit of the maximum regular number of the corresponding data type.
[object Object]undefined
Each operator has [object Object]two-phase API calls[object Object]. You must call aclnnDynamicDualLevelMxQuantGetWorkspaceSize to obtain the workspace size required for computation and the executor that contains the operator computation process, and then call aclnnDynamicDualLevelMxQuant to perform the computation.
Parameters
[object Object]Returns
[object Object]: status code. For details, see .The first-phase API implements input parameter validation. The following error codes may be returned.
[object Object]
- The restrictions on the shapes of x, level0ScaleOut, and level1ScaleOut are as follows:
- rank(level1ScaleOut) = rank(x) + 1.
- level0ScaleOut.shape[-1] = ceil(x.shape[-1] / level0Blocksize).
- level1ScaleOut.shape[-2] = (ceil(x.shape[-1] / level1Blocksize) + 2 - 1) / 2.
- level1ScaleOut.shape[-1] = 2.
- The shapes of other dimensions are consistent with those of input x.
- Deterministic description: The aclnnDynamicDualLevelMxQuant is implemented in deterministic mode by default.
The following example is for reference only. For details, see .